本帖最后由 水木子 于 2010-9-21 15:41 编辑
#include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $sTest
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
$hGUI = GUICreate("Treeview", 400, 300)
$Treeview = GUICtrlCreateTreeView(2, 2, 180, 294, $iStyle, $WS_EX_CLIENTEDGE)
$Fonts1 = GUICtrlCreateTreeViewItem("项目1", $Treeview)
GUICtrlCreateTreeViewItem("项目1-1", $Fonts1)
GUICtrlCreateTreeViewItem("项目1-2", $Fonts1)
GUICtrlCreateTreeViewItem("项目1-3", $Fonts1)
GUICtrlSetState($Fonts1, $GUI_EXPAND)
$Fonts2 = GUICtrlCreateTreeViewItem("项目2", $Treeview)
GUICtrlCreateTreeViewItem("项目2-1", $Fonts2)
GUICtrlCreateTreeViewItem("项目2-2", $Fonts2)
GUICtrlCreateTreeViewItem("项目2-3", $Fonts2)
GUICtrlSetState($Fonts2, $GUI_EXPAND)
$Button1 = GUICtrlCreateButton("获取", 264, 96, 75, 25, $WS_GROUP)
GUISetState()
While 1
Switch GUIGetMsg()
Case - 3
Exit
Case $Button1
$sTest = ''
For $i = 4 To 11
If BitAND(GUICtrlRead($i), $GUI_CHECKED) Then $sTest &= _GUICtrlTreeView_GetText($Treeview, $i) & @CRLF
Next
MsgBox(0, '被选项目文本', $sTest)
EndSwitch
WEnd
|