其实论坛里搜索一下就有了,08年的老号啊
#include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
$hGUI = GUICreate("Treeview", 400, 300)
$hTreeview = GUICtrlCreateTreeView(2, 2, 180, 294, $iStyle, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, 'shell32.dll', 14)
$hFitem01 = GUICtrlCreateTreeViewItem("项目1", $hTreeview)
$hSitem01 = GUICtrlCreateTreeViewItem("项目1-1", $hFitem01)
$hSitem02 = GUICtrlCreateTreeViewItem("项目1-2", $hFitem01)
$hSitem03 = GUICtrlCreateTreeViewItem("项目1-3", $hFitem01)
GUICtrlSetState($hFitem01, $GUI_EXPAND)
$hFitem02 = GUICtrlCreateTreeViewItem("项目2", $hTreeview)
$hSitem11 = GUICtrlCreateTreeViewItem("项目2-1", $hFitem02)
$hSitem12 = GUICtrlCreateTreeViewItem("项目2-2", $hFitem02)
$hSitem13 = GUICtrlCreateTreeViewItem("项目2-3", $hFitem02)
GUICtrlSetState($hFitem02, $GUI_EXPAND)
$hListBox1 = GUICtrlCreateList("", 185, 2, 213, 295)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case - 3
Exit
Case $hFitem01, $hFitem02
If BitAND(GUICtrlRead($hFitem01), $GUI_CHECKED) Then
GUICtrlSetState($hSitem01, $GUI_CHECKED)
GUICtrlSetState($hSitem02, $GUI_CHECKED)
GUICtrlSetState($hSitem03, $GUI_CHECKED)
ElseIf BitAND(GUICtrlRead($hFitem01), $GUI_UNCHECKED) Then
GUICtrlSetState($hSitem01, $GUI_UNCHECKED)
GUICtrlSetState($hSitem02, $GUI_UNCHECKED)
GUICtrlSetState($hSitem03, $GUI_UNCHECKED)
EndIf
If BitAND(GUICtrlRead($hFitem02), $GUI_CHECKED) Then
GUICtrlSetState($hSitem11, $GUI_CHECKED)
GUICtrlSetState($hSitem12, $GUI_CHECKED)
GUICtrlSetState($hSitem13, $GUI_CHECKED)
ElseIf BitAND(GUICtrlRead($hFitem02), $GUI_UNCHECKED) Then
GUICtrlSetState($hSitem11, $GUI_UNCHECKED)
GUICtrlSetState($hSitem12, $GUI_UNCHECKED)
GUICtrlSetState($hSitem13, $GUI_UNCHECKED)
EndIf
Case $hSitem01, $hSitem02, $hSitem03, $hSitem11, $hSitem12, $hSitem13
If BitAND(GUICtrlRead($hSitem01), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem02), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem03), $GUI_CHECKED) = 1 Then
GUICtrlSetState($hFitem01, $GUI_CHECKED)
Else
GUICtrlSetState($hFitem01, $GUI_UNCHECKED)
EndIf
If BitAND(GUICtrlRead($hSitem11), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem12), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem13), $GUI_CHECKED) = 1 Then
GUICtrlSetState($hFitem02, $GUI_CHECKED)
Else
GUICtrlSetState($hFitem02, $GUI_UNCHECKED)
EndIf
EndSwitch
WEnd
|