Basic Univers
Info.TV_HITTESTINFO
If OpenWindow(0, 0, 0, 355, 180, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "TreeGadget")
If CreateGadgetList(WindowID(0))
TreeGadget(0, 10, 10, 160, 160)
For a = 0 To 10
AddGadgetItem(ID, - 1, "Normal Item " + Str(a))
AddGadgetItem(ID, - 1, "Node " + Str(a))
OpenTreeGadgetNode(ID)
AddGadgetItem(ID, - 1, "Sub-Item 1")
AddGadgetItem(ID, - 1, "Sub-Item 2")
AddGadgetItem(ID, - 1, "Sub-Item 3")
AddGadgetItem(ID, - 1, "Sub-Item 4")
CloseTreeGadgetNode(ID)
AddGadgetItem(ID, - 1, "File " + Str(a))
Next
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_EventGadget
Select EventGadgetID()
Case 0
If EventType() = #PB_EventType_LeftClick
GetCursorPos_(@Pos.POINT)
ScreenToClient_(GadgetID(0), @Pos.POINT)
Info\pt\x = Pos\x : Info\pt\y = Pos\y
SendMessage_(GadgetID(0), #TVM_HITTEST, 0, @Info)
If Info\flags & #TVHT_ONITEMBUTTON
SendMessage_(GadgetID(0), #TVM_SELECTITEM, #TVGN_CARET, Info\hItem)
Debug "L'élément " + Str(GetGadgetState(0))+" a été selectionné"
EndIf
If GetGadgetItemState(0, GetGadgetState(0)) &#PB_Tree_Expanded
Debug "la branche est ouverte"
ElseIf GetGadgetItemState(0, GetGadgetState(0)) &#PB_Tree_Collapsed
Debug "la branche est fermée"
EndIf
EndIf
EndSelect
Case #PB_EventCloseWindow
Quit = #True
EndSelect
Until Quit
EndIf