|
-
Feb 7th, 2001, 08:37 PM
#1
Thread Starter
Junior Member
Does anyone knows how you can get the handle of a window thats behind another window. I have an application running on top of internet explorer, i need to get the handle of internet explorer thats behind the application. Please help mi, i'm new to this.
Thanks
-
Feb 7th, 2001, 08:50 PM
#2
Use the FindWindow API function.
Code:
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
hWin = FindWindow("IEFrame", vbNullString)
If hWin <> 0 Then
Msgbox "IE's handle: " & hWin
Else
Msgbox "IE not found"
End If
End Sub
-
Feb 7th, 2001, 10:02 PM
#3
Thread Starter
Junior Member
Thanks it works. I found a description of the FindWindow function, it wrtoe:
The FindWindow function retrieves the handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows.
What do you mean by top-level window??? In my case i got the handle of the IE behind the application. When i open another IE and minimize all the IE windows(now i got 2 IE opened), i got the handle of the new IE window that i opened.
Thanks
-
Feb 10th, 2001, 10:48 PM
#4
When it says top level window, it is referring to the main window of an application. The main window will contain many windows inside it. These are child windows. They dont have to actually be "windows" though. Buttons, list boxes, etc. are all considered child windows. To search for the handles of these objects, read up on the findwindowex routine. To get the handle of All Open IE windows, Use FindwindowEx also. Plug the handle of the Last found IE into i t, and it will return the next handle. Keep this up for any number of ie windows open.
example code:
dim Parent as long
dim LastWindowFound as long
Parent = 0 '0 is the desktop, which is parent to top-lev. LastWindowFound = 0
do
hWin = FindWindowEx(Parent, LastWindowFound, "IEFrame", vbNullString)
If hWin <> 0 Then
Msgbox "IE's handle: " & hWin
Else
Msgbox "IE not found"
End If
LastWindowFound = hWin
loop until hWin = 0
Last edited by Lord Orwell; Feb 10th, 2001 at 11:01 PM.
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
|