I'd like to get the handle of the first node above a specified node. The two nodes are not visible, nor selected.
I could get use Get Previous or Get Parent to get a node higher up the Tree, and then walk downward (here's my latest code for downward tree walking), but I haven't figured how to modify the approach to walk up a tree. Walking down the tree would work, but I was looking for a less "brute force" way of doing it.
Here's the description of treewalking definition that I'm using.
Using the TVM_GetNextItem message, with TGVN_PreviousVisible is close to what I want, but it only works if the desired node is visible, and I can't force the node to be visible unless I know the node. Plus, I really don't want the Tree to be jumping around.
Any thoughts?
I could get use Get Previous or Get Parent to get a node higher up the Tree, and then walk downward (here's my latest code for downward tree walking), but I haven't figured how to modify the approach to walk up a tree. Walking down the tree would work, but I was looking for a less "brute force" way of doing it.
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
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
Any thoughts?
Comment