Private Declare Function GetDesktopWindow Lib "user32" () As Long
Sub ShowWindowsInTrewView(tvw As TreeView, Optional ByVal hWnd As Long, _ Optional ParentNode As MSComctlLib.Node) Dim winHandles() As Long Dim i As Long Dim Node As MSComctlLib.Node If ParentNode Is Nothing Then hWnd = GetDesktopWindow() Set Node = tvw.Nodes.Add(, , , WindowDescription(hWnd)) Node.Expanded = True Else Set Node = tvw.Nodes.Add(ParentNode.Index, tvwChild, , _ WindowDescription(hWnd)) End If winHandles() = ChildWindows(hWnd) For i = 1 To UBound(winHandles) ShowWindowsInTrewView tvw, winHandles(i), Node Next End Sub |