|
-
Apr 2nd, 2002, 03:56 PM
#1
Thread Starter
Hyperactive Member
FindWindowEx to get MDI Child handle?
Can anyone explain to me how to use the FindWindowEx function to get the handle of a mdi child?
I used
Code:
WinWnd = FindWindow(vbNullString, "My App Title")
to get the handle of the parent window. But when I try
Code:
bWnd = FindWindowEx(WinWnd, ByVal 0&, vbNullString, "My Child Title")
bWnd is always 0...
"MyChildTitle 1" is the only child form under the parent. I've tried with two children but it still wont pick up any of them...any ideas?
Thanks.
Last edited by brenaaro; Apr 2nd, 2002 at 04:04 PM.
-
Apr 2nd, 2002, 04:14 PM
#2
FindWindowEx only finds parent windows.
After you have the handle to the parent MDI window then call EnumChildWindows
MDIhWnd is the handle of the parent
Code:
'in a form
Private Function GetChild(MDIhWnd as long) as long
Dim MDIhnd as long
Me.AutoRedraw = True
EnumChildWindows MDIhWnd, AddressOf EnumChildProc, ByVal 0&
End Function
'in a module
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
'Get the windowtext length
sSave = Space$(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText hwnd, sSave, Len(sSave)
'remove the last Chr$(0)
sSave = Left$(sSave, Len(sSave) - 1)
If sSave <> "" Then Form1.Print sSave
'continue enumeration
EnumChildProc = 1
End Function
-
Apr 2nd, 2002, 04:28 PM
#3
Thread Starter
Hyperactive Member
Thanks Jim, I had seen the EnumFunction in the API guide but I wasn't sure it was what I needed since the decription of FindWindowEx said it searched child windows.
Anyways, it worked, I got the handle, thanks a bunch =)
-
Mar 13th, 2019, 02:20 AM
#4
Registered User
Re: FindWindowEx to get MDI Child handle?
 Originally Posted by brenaaro
Thanks Jim, I had seen the EnumFunction in the API guide but I wasn't sure it was what I needed since the decription of FindWindowEx said it searched child windows.
Anyways, it worked, I got the handle, thanks a bunch =)
Hi Thread Starter ! Have you Finished this code ? Please Please share me , i'm stucking with the same problem !
Please show me your code
Thanks you so much !
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
|