dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
May 26, 2001

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


ShowWindowsInTreeView - Display a windows hierarchy in a treeview control

Private Declare Function GetDesktopWindow Lib "user32" () As Long

' Display all the child window of a given window in a TreeView control
' omit 2nd and 3rd argument to display the entire Windows hierarchy, as in
'    ShowWindowsInTreeView TreeView1
'
' NOTES: requires the ChildWindows and WindowDescription routines.

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
        ' If no Parent node, this is the desktop window
        hWnd = GetDesktopWindow()
        ' add the root node and expand it
        Set Node = tvw.Nodes.Add(, , , WindowDescription(hWnd))
        Node.Expanded = True
    Else
        ' add a child node
        Set Node = tvw.Nodes.Add(ParentNode.Index, tvwChild, , _
            WindowDescription(hWnd))
    End If
    
    ' get the child windows of this window
    winHandles() = ChildWindows(hWnd)
    
    For i = 1 To UBound(winHandles)
        ' Recursively call this routine to show this window's children.
        ShowWindowsInTrewView tvw, winHandles(i), Node
    Next
    
End Sub

Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date