Context: |
Function |
Library/Class: |
WinAPIWrapper |
Function GetWindowList() As
GetWindowList (Byval hWnd As Long, Byval pWnd As Long, WinLst() As WinList, NoOfWindows As Integer, Byval Level As Integer, Byval MaxLvl As Integer) As Integer
GetWindowList returns a list (WinList) of ALL child windows to the passed on window handle (hWnd). If hWnd is 0 (zero) then GetWindowList will assume the Windows' Desktop window to be the top level parent. The first element in the list will contain the information about the passed on window handle (hWnd) or the Windows' Desktop window (in case hWnd = 0).
The details returned in the window list (WinList) are the Task ID, Title, Window Handle, Class Name, Parent Window and the Child Level as to the top parent window. GetWindowList is a recursive function calling itself until no further child windows are found.
Parameters:
hWnd (Byval, Long)
Window handle which list of child windows are to be retrieved.
pWnd (Byval, Long)
Window handle to the parent window of hWnd.
WinLst (WinList)
Blank (empty) window list to be used as return parameter. For further details refer to the type definition of WinList.
NoOfWindows (Integer)
Number of child windows found. The first call value should be 0
Level (Integer)
Current recursive level. The first call value should be -1.
MaxLvl (Integer)
Maximum recursive level to be searched for child windows. If hWnd is passed on as 0 (zero), then MaxLvl will be set to 0 (zero) and only the first level child windows to the Windows Desktop will be returned.
Return Values:
Parameter WinLst (WinList)
Array of type WinList containing the details of collected child windows.
Integer. Number of elements (windows) returned in WinLst.
Example:
Dim WList() As WinList
Dim CList() As WinList
Dim ChildWindows As Integer
Call GetTopLevelWindows(WList)
Forall Win In WList
ChildWindows = GetWindowList(Win.hWnd, Win.pWnd, CList, 0 , -1, 10)
If Win.ClassName = "OpusApp" Then
Call MessageDialog("Found <" & ChildWindows & _
"] Open Child Windows for Word Task.", _
0,"GetWindowList Example")
Elseif Win.ClassName = "XLMAIN" Then
Call MessageDialog("Found <" & ChildWindows & _
"] Open Child Windows for Excel Task.", _
0,"GetWindowList Example")
Else
Call MessageDialog("Found <" & ChildWindows & _
"] Open Child Windows for Unknown Task.", _
0,"GetWindowList Example")
End If
End Forall
|