Here's the revised version. Now we're talking about minimal code - only 11 lines of code if you don't count the SUB/DIM/End Sub statements!
Code:
Sub TreeWalk2(ByVal hWnd As Dword, ByVal hNode As Dword) Dim iReturn As Dword, hSibling As Dword Do Treeview Get Child hWnd, %ID_Treeview, hNode To iReturn 'get child (1st choice) If iReturn = 0 Then Treeview Get Next hWnd, 100, hNode To iReturn 'or sibling (2nd choice) If iReturn = 0 Then 'no child or sibling Do 'get sibling of first parent with sibling Treeview Get Parent hWnd, %ID_TreeView, hNode To hNode 'parent Treeview Get Next hWnd, %ID_TreeView, hNode To iReturn 'sibling child of parent Loop Until iReturn Or (hNode = 0) 'stop when find sibling of parent with sibling, or no more choices End If hNode = iReturn 'possible values: 0, zero (no parent/no sibling), <>0 (parent or sibling) Sleep 250 : If iReturn Then Treeview Select hWnd, %ID_TreeView, hNode Loop While hNode End Sub
Leave a comment: