开发者

How can I check the expanded state of a tree view control with Win32::GuiTest?

In the Win32::GuiTest documentation I can only find two functions for dealing with tree controls, GetTreeViewSelPath and SelTreeViewItemPath. Can anyone re开发者_运维技巧commend a way to detect the open/closed state of the nodes in the tree?


My tree view actually is actually a "forest" (a bunch of trees). I found I can traverse the roots with:

my $i = 0;
my @states;
for (my $node = Win32::GuiTest::SendMessage($windows[0], 
                    0x1100 + 10, # Get next
                    0,           # root
                    0);          # N/A
 $node != 0;
 $node = Win32::GuiTest::SendMessage($windows[0], 
                     0x1100 + 10, # Get next
                     1,           # Sibling
                     $node)) {    # from current

my $state = Win32::GuiTest::SendMessage($windows[0], 0x1100 + 39,
                    $node, 0xff);
$states[$i] = $state;
$i++;
}

I found the constants (root, sibling, etc.) at http://www.xtremevbtalk.com/showthread.php?t=45515:

' messages
Public Const TV_FIRST = &H1100
Public Const TVM_GETNEXTITEM = (TV_FIRST + 10)
Public Const TVM_GETITEM = (TV_FIRST + 12)

' TVM_GETNEXTITEM wParam values
Public Enum TVGN_Flags
TVGN_ROOT = &H0
TVGN_NEXT = &H1
TVGN_PREVIOUS = &H2
TVGN_PARENT = &H3
TVGN_CHILD = &H4
TVGN_FIRSTVISIBLE = &H5
TVGN_NEXTVISIBLE = &H6
TVGN_PREVIOUSVISIBLE = &H7
TVGN_DROPHILITE = &H8
TVGN_CARET = &H9

If I had a normal tree, I might have done:

node = root
for (node = child; node != 0; node = sibling) {
   ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜