|
-
Jul 29th, 2003, 12:33 PM
#1
Thread Starter
Frenzied Member
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!
-
Jul 29th, 2003, 12:48 PM
#2
there are API 2 functions
EnumChildWindows
EnumWindows
might help you out?
-
Jul 29th, 2003, 12:50 PM
#3
Thread Starter
Frenzied Member
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!
-
Jul 29th, 2003, 12:57 PM
#4
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) _
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
-
Jul 29th, 2003, 01:06 PM
#5
Thread Starter
Frenzied Member
Thats what it was - thanks alot! I was stuck for a while on that one...
-
Jul 29th, 2003, 01:07 PM
#6
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:
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetNextWindow Lib "user32.dll" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
Private Sub Command1_Click()
Dim hwnd As Long, chwnd As Long
hwnd = FindWindow("Notepad", vbNullString)
If Not hwnd = 0 Then
chwnd = GetNextWindow(hwnd, 1)
End If
MsgBox "the notepad handle is: " & hwnd & Chr(10) & " the edit window is: " & chwnd, vbInformation
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|