is there a way to find handles of all windows existing on current window (window hwnd is given)?
thx
Printable View
is there a way to find handles of all windows existing on current window (window hwnd is given)?
thx
Yes. You can use the :
Code:Public Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
How to use EnumChilWindows: http://www.vbapi.com/ref/e/enumchildwindows.html.
Add to a Module.
Add to a Form.Code: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) & "-" & hwnd
End If
EnumWindowsProc = 1
End Function
Code:Private Sub Form_Load()
EnumWindows AddressOf EnumWindowsProc, 0
End Sub