Results 1 to 6 of 6

Thread: FindWindowEx Question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Question FindWindowEx Question

    I am very familiar with how to find a window and then another control that is a child of it. But not sure how to do this.

    Suppose I use FindWindow to find Notepad. Now I want to find a control called "Static_Text" but I want the second Static_Text control under the parent Notepad. I use FindWindowEx to find the first one. How to I continue the search from there to look for the next? I know I could loop using the GetNextWindow until I find it but I remember there is a way to continue searching. Does anyone know how?

    Can someone show me a small example?

    Thanks!

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    there are API 2 functions

    EnumChildWindows
    EnumWindows

    might help you out?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463
    Thanks but there is a way to use the FindWindowEx to continue searching under the parent handle.

    Does anyone know how to use this?

    Thanks!

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, _
    2.                                                                           ByVal hWnd2 As Long, _
    3.                                                                           ByVal lpsz1 As String, _
    4.                                                                           ByVal lpsz2 As String) _
    5.                                                                           As Long

    For hwnd2, pass in the handle that you got in the previous call.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463
    Thats what it was - thanks alot! I was stuck for a while on that one...

  6. #6
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    you need to be using GetNextWindow , here's a simple example ( make sure you open a notepad up to see it work or it'll just return 0's )
    VB Code:
    1. Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. Private Declare Function GetNextWindow Lib "user32.dll" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
    3.  
    4. Private Sub Command1_Click()
    5. Dim hwnd As Long, chwnd As Long
    6.  
    7. hwnd = FindWindow("Notepad", vbNullString)
    8.  
    9. If Not hwnd = 0 Then
    10.     chwnd = GetNextWindow(hwnd, 1)
    11. End If
    12.  
    13. MsgBox "the notepad handle is: " & hwnd & Chr(10) & " the edit window is: " & chwnd, vbInformation
    14.  
    15. End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width