PDA

Click to See Complete Forum and Search --> : Handles!


Mine_23
Feb 8th, 2001, 10:02 AM
Hello;
Can someone tell me how to retrieve all the 'handles' of all the Windows.

jonaxse
Feb 8th, 2001, 10:26 AM
I personally haven`t tried this yet. :D

But there is a web site that can help you.

http://www.allapi.net/

Plus, they have an API-Guide (with tons of examples, and a list of API Functions)....
.... and an API-Toolshed, a replacement for VB`s API Viewer utility.
(Download for FREE!)

Here is a start: EnumWindows API Function Call

The EnumWindows function enumerates all top-level windows on the screen by passing the handle of each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.

Search for this function on the site, they have an example.

Feb 8th, 2001, 03:35 PM
Add to a Module

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
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim sName As String
Dim Temp As String
Static iCount As Integer

iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1

If Length > 1 Then
sName = Space(Length)
GetWindowText hwnd, sName, Length
Debug.Print Left(sName, Length - 1)
End If

EnumWindowsProc = 1
End Function


now use this line to display them (in the debug window)

'EnumWindows AddressOf EnumWindowsProc, 0

Lord Orwell
Feb 10th, 2001, 02:59 AM
I prefer the FindWindowEx function. You can use this to enumerate all top level windows, and then plug in each of their handles to enumerate the lower level child windows and so on. Read up on it. I love this function. You can search by class or window name if you so choose, etc.

Feb 10th, 2001, 10:19 AM
You can find the child windows but using the EnumChildwindows function.