ChildWindows – Get all the child windows of another window

Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, _    ByVal lParam As Long) As LongPrivate Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As _    Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long' The following variables are shared between the main ChildWindows procedure' and the auxiliary (private) ChildWindows_CBK routine' An array of Long holding the handle of all child windows.Dim windows() As Long' The number of elements in the array.Dim windowsCount As Long' Return an array of Long holding the handles of all the child windows' of a given window. If hWnd = 0 it returns all the top-level windows.Function ChildWindows(ByVal hWnd As Long) As Long()    windowsCount = 0    If hWnd Then        EnumChildWindows hWnd, AddressOf EnumWindows_CBK, 1    Else        EnumWindows AddressOf EnumWindows_CBK, 1    End If    ' Trim uninitialized elements and return to caller.    ReDim Preserve windows(windowsCount) As Long    ChildWindows = windows()End Function' The callback routine, common to both EnumWindows and EnumChildWindows.Private Function EnumWindows_CBK(ByVal hWnd As Long, ByVal lParam As Long) As _    Long    ' Make room in the array, if necessary.    If windowsCount = 0 Then        ReDim windows(100) As Long    ElseIf windowsCount >= UBound(windows) Then        ReDim Preserve windows(windowsCount + 100) As Long    End If    ' Store the new item.    windowsCount = windowsCount + 1    windows(windowsCount) = hWnd    ' Return 1 to continue enumeration.    EnumWindows_CBK = 1End Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS