Ticket #378: _GUICtrlTreeView_Expand.au3

File _GUICtrlTreeView_Expand.au3, 1.6 KB (added by Wooltown, 13 years ago)
Line 
1#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
2#include <GuiConstantsEx.au3>
3#include <GuiTreeView.au3>
4#include <WindowsConstants.au3>
5
6Opt('MustDeclareVars', 1)
7
8$Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
9
10_Main()
11
12Func _Main()
13
14        Local $hItem[5], $hTreeView, $kitem[5][3]
15        Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
16       
17        GUICreate("TreeView Expand", 400, 300)
18
19        $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
20        GUISetState()
21
22        _GUICtrlTreeView_BeginUpdate($hTreeView)
23        For $x = 0 To 4
24                $hItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $hTreeView)
25                For $y = 0 To 2
26                        $kitem[$x][$y] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $hItem[$x])
27                        For $z = 0 To 2
28                                GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $z), $kItem[$x][$y])
29                        Next
30                Next
31        Next
32        _GUICtrlTreeView_EndUpdate($hTreeView)
33
34        MsgBox(4160, "Information", "Expand All")
35        _GUICtrlTreeView_Expand($hTreeView)
36       
37        MsgBox(4160, "Information", "Collapse All")
38        _GUICtrlTreeView_Expand($hTreeView, 0, False)
39       
40        MsgBox(4160, "Information", "Expand item 2-2")
41        _GUICtrlTreeView_Expand($hTreeView, $kItem[2][2])
42
43        MsgBox(4160, "Information", "Collapse item 2-2")
44        _GUICtrlTreeView_Expand($hTreeView, $kItem[2][2], False)
45
46        ; Loop until user exits
47        Do
48        Until GUIGetMsg() = $GUI_EVENT_CLOSE
49        GUIDelete()
50EndFunc   ;==>_Main