#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Global $hTreeView
Local $GUI, $hItem
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
$GUI = GUICreate("TreeView", 400, 300)
$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
_GUICtrlTreeView_BeginUpdate($hTreeView)
$hItem = _GUICtrlTreeView_Add($hTreeView, 0, "New_Item")
_GUICtrlTreeView_AddChild($hTreeView, $hItem, "New_Child")
_GUICtrlTreeView_AddChild($hTreeView, $hItem, "New_Child_2")
_GUICtrlTreeView_AddChild($hTreeView, $hItem, "New_Child_3")
_GUICtrlTreeView_EndUpdate($hTreeView)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
$hWndTreeview = $hTreeView
If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTreeview
Switch $iCode
Case $NM_DBLCLK
MsgBox(64, ":)", $text)
Return 0
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc