|
-
Aug 12th, 2000, 04:01 PM
#1
Thread Starter
Member
To Find the Handle of a Window you use the FindWindow API. But what would one use to find the handle of a Child Window?. Can somebody please Give me an example of finding a Child Window. Thanx
-
Aug 12th, 2000, 04:14 PM
#2
Use FindWindowEx. Next example will get the hWnd of the TextBox inside Notepad.
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
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim hParent As Long
Dim hChild As Long
'Get the handle of Notepad
hParent = FindWindow("Notepad", vbNullString)
'Get the handle of the TextBox inside Notepad
hChild = FindWindowEx(hParent, 0&, "Edit", vbNullString)
End Sub
-
Aug 12th, 2000, 04:36 PM
#3
Thread Starter
Member
Thank you Megatron you have been very helpful. Can you find a child window by its Class or by it't Title? is there an API for that?
-
Aug 12th, 2000, 04:39 PM
#4
Thread Starter
Member
For Example: FindChildByTitle(hwnd,"")
or: FindChildByClass(hwnd,"")...
-
Aug 12th, 2000, 07:45 PM
#5
Yes, FindWindowEx allows for both. The last argument specifies the Window title and the 2nd last argument specifies the ClassName.
For example, if you wanted to find a Button, you would use
Code:
hChild = FindWindowEx(hParent, 0&, "Button", vbNullString)
If you wanted to find a window that has the text of "Hello!" you would use.
Code:
hChild = FindWindowEx(hParent, 0&, vbNullString, "Hello!")
-
Aug 12th, 2000, 11:59 PM
#6
Fanatic Member
Somebody goofed when they put together the winapi.txt file from the API Viewer
I found the following declaration for findwindowex much more descriptive:
Code:
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
|