#PRE_UseX64=n
#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
Opt('GUIOnEventMode', 1)
Global $MainForm = GUICreate("TreeView Set Checked", 400, 300)
Global $TreeView = GUICtrlCreateTreeView(0, 0, 300, 200, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES))
Global $TreeViewP1 = GUICtrlCreateTreeViewItem("父节点1", $TreeView)
Global $TreeViewC11 = GUICtrlCreateTreeViewItem("子节点1", $TreeViewP1)
Global $TreeViewC12 = GUICtrlCreateTreeViewItem("子节点2", $TreeViewP1)
Global $TreeViewP2 = GUICtrlCreateTreeViewItem("父节点2", $TreeView)
Global $TreeViewC21 = GUICtrlCreateTreeViewItem("子节点1", $TreeViewP2)
Global $TreeViewC22 = GUICtrlCreateTreeViewItem("子节点2", $TreeViewP2)
GUISetState()
GUICtrlSetOnEvent($TreeViewP1, '_SetTreeChecked')
GUICtrlSetOnEvent($TreeViewP2, '_SetTreeChecked')
GUISetOnEvent(-3, '_exit')
While 1
Sleep(20)
WEnd
Func _SetTreeChecked()
Local $hChild = _GUICtrlTreeView_GetFirstChild($TreeView, _GUICtrlTreeView_GetSelection($TreeView))
While $hChild
_GUICtrlTreeView_SetChecked($TreeView, $hChild, _GUICtrlTreeView_GetChecked($TreeView, _GUICtrlTreeView_GetSelection($TreeView)))
$hChild = _GUICtrlTreeView_GetNextChild($TreeView, $hChild)
WEnd
EndFunc ;==>_SetTreeChecked
Func _exit()
Exit
EndFunc ;==>_exit
|