EnumChildWindows function
Applies to: desktop apps only
Enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE.
Syntax
BOOL WINAPI EnumChildWindows( __in_opt HWND hWndParent, __in WNDENUMPROC lpEnumFunc, __in LPARAM lParam );
Parameters
- hWndParent [in, optional]
-
Type: HWND
A handle to the parent window whose child windows are to be enumerated. If this parameter is NULL, this function is equivalent to EnumWindows.
- lpEnumFunc [in]
-
Type: WNDENUMPROC
A pointer to an application-defined callback function. For more information, see EnumChildProc.
- lParam [in]
-
Type: LPARAM
An application-defined value to be passed to the callback function.
Return value
Type:
Type: BOOL
The return value is not used.
Remarks
If a child window has created child windows of its own, EnumChildWindows enumerates those windows as well.
A child window that is moved or repositioned in the Z order during the enumeration process will be properly enumerated. The function does not enumerate a child window that is destroyed before being enumerated or that is created during the enumeration process.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Reference
- EnumChildProc
- EnumThreadWindows
- EnumWindows
- GetWindow
- Conceptual
- Windows
Send comments about this topic to Microsoft
Build date: 2/3/2012
- 2/20/2009
- Simon Said
- 6/14/2009
- Thomas Lee
Friend Declare Function EnumChildWindows Lib "user32.dll" (ByVal hWndParent As Int32, ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Int32) As BooleanExample: (this example is part of class that represents Win32 native window)
''' <summary>Adds <paramref name="item"/> to <paramref name="List"/> and returns true</summary>
''' <param name="List"><see cref="List(Of T)"/> to add item to</param>
''' <param name="item">Item to be added</param>
''' <typeparam name="T">Type of <paramref name="item"/></typeparam>
''' <returns>True</returns>
Private Shared Function AddToList(Of T)(ByVal List As List(Of T), ByVal item As T) As Boolean
List.Add(item)
Return True
End Function
''' <summary>Gets all childrens of current windows</summary>
''' <returns>Childrens of current window</returns>
''' <exception cref="API.Win32APIException">Error while enumerating windows. Ie. <see cref="Handle"/> is invalid</exception>
<Category("Relationship")> _
<TypeConverter(GetType(CollectionConverter))> _
Public ReadOnly Property Children() As IReadOnlyList(Of Win32Window) 'Localize: description
Get
Dim List As New List(Of Win32Window)
If API.EnumChildWindows(hWnd, New API.EnumWindowsProc(Function(hWnd As Integer, lParam As Integer) AddToList(List, New Win32Window(hWnd))), 0) Then
Return New ReadOnlyListAdapter(Of Win32Window)(List)
Else
Dim ex As New API.Win32APIException
If ex.NativeErrorCode <> 0 Then
Throw ex
Else
Return New ReadOnlyListAdapter(Of Win32Window)(List)
End If
End If
End Get
End Property
- 12/7/2007
- Đonny
- 1/25/2008
- Noelle Mallory