如何使用Win32 :: GuiTest检查树视图控件的展开状态?

时间:2011-04-13 20:43:35

标签: perl winapi

Win32::GuiTest documentation中,我只能找到两个用于处理树控件的函数GetTreeViewSelPathSelTreeViewItemPath。任何人都可以推荐一种方法来检测树中节点的打开/关闭状态吗?

1 个答案:

答案 0 :(得分:0)

我的树视图实际上实际上是一个“森林”(一堆树)。我发现我可以通过以下方式遍历根源:

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++;
}

我在http://www.xtremevbtalk.com/showthread.php?t=45515找到了常量(root,sibling等):

' 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

如果我有一棵普通的树,我可能会这样做:

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