#include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
$hGUI = GUICreate("Treeview", 600, 450)
$Treeview = GUICtrlCreateTreeView(5, 5, 180, 440, $iStyle, $WS_EX_CLIENTEDGE)
$Fonts1 = GUICtrlCreateTreeViewItem("项目1", $Treeview)
$Font11 = GUICtrlCreateTreeViewItem("项目1-1", $Fonts1)
$Font12 = GUICtrlCreateTreeViewItem("项目1-2", $Fonts1)
$Font13 = GUICtrlCreateTreeViewItem("项目1-3", $Fonts1)
GUICtrlSetState($Fonts1, $GUI_EXPAND)
$Fonts2 = GUICtrlCreateTreeViewItem("项目2", $Treeview)
$Font21 = GUICtrlCreateTreeViewItem("项目2-1", $Fonts2)
$Font22 = GUICtrlCreateTreeViewItem("项目2-2", $Fonts2)
$Font23 = GUICtrlCreateTreeViewItem("项目2-3", $Fonts2)
GUICtrlSetState($Fonts2, $GUI_EXPAND)
$Fonts3 = GUICtrlCreateTreeViewItem("项目3", $Treeview)
$Font31 = GUICtrlCreateTreeViewItem("项目3-1", $Fonts3)
$Font32 = GUICtrlCreateTreeViewItem("项目3-2", $Fonts3)
$Font33 = GUICtrlCreateTreeViewItem("项目3-3", $Fonts3)
GUICtrlSetState($Fonts3, $GUI_EXPAND)
$Fonts4 = GUICtrlCreateTreeViewItem("项目4", $Treeview)
$Font41 = GUICtrlCreateTreeViewItem("项目4-1", $Fonts4)
$Font42 = GUICtrlCreateTreeViewItem("项目4-2", $Fonts4)
$Font43 = GUICtrlCreateTreeViewItem("项目4-3", $Fonts4)
GUICtrlSetState($Fonts4, $GUI_EXPAND)
$Label1 = GUICtrlCreateLabel("", 350, 150, 200, 24)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case - 3
Exit
Case $Font11, $Font12, $Font13, $Font21, $Font22, $Font23, $Font31, $Font32, $Font33, $Font41, $Font42, $Font43
$Text = _GUICtrlTreeView_GetText($Treeview, _GUICtrlTreeView_GetSelection($Treeview))
GUICtrlSetData($Label1, $Text)
EndSwitch
WEnd