Friend Declare Function EnumChildWindows Lib "user32.dll" (ByVal hWndParent As Int32, ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Int32) As Boolean
Example: (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