Code : Tout sélectionner
If OpenWindow(0,10,10,450,400,#PB_Window_ScreenCentered|#PB_Window_SystemMenu, "TreegadgetWorking")
If CreateGadgetList(WindowID(0))
TreeGadget(10,0,0,300,400)
ButtonGadget(20,300,0,150,30,"Ajouter une arborescence")
ButtonGadget(21,300,30,150,30,"Supprimer 5 et son fils")
DisableGadget(21,1)
ButtonGadget(22,300,60,150,30,"Fin")
DisableGadget(22,1)
EndIf
EndIf
Procedure CountTreeGadgetNodeItems(Gadget.l,Item.l)
For i=item+1 To CountGadgetItems(10)-1
If GetGadgetItemAttribute(10,i,#PB_Tree_SubLevel)=0
Break
Else
nbfils=nbfils+1
EndIf
Next
ProcedureReturn nbfils
EndProcedure
Repeat
EventID=WaitWindowEvent()
GadgetID=EventGadget()
MenuID=EventMenu()
Select EventID
Case #PB_Event_Gadget
Select GadgetID
Case 10
Debug GetGadgetState(10)
Case 20
AddGadgetItem(10,0,"1",0,0)
AddGadgetItem(10,1,"2",0,1)
SetGadgetItemState(10, 0, #PB_Tree_Expanded )
AddGadgetItem(10,2,"3",0,2)
SetGadgetItemState(10, 1, #PB_Tree_Expanded )
AddGadgetItem(10,3,"4",0,2)
SetGadgetItemState(10, 1, #PB_Tree_Expanded )
AddGadgetItem(10,4,"5",0,1)
SetGadgetItemState(10,0, #PB_Tree_Expanded )
AddGadgetItem(10,5,"6",0,0)
AddGadgetItem(10,5,"7",0,2)
SetGadgetItemState(10,4, #PB_Tree_Expanded )
AddGadgetItem(10,6,"8",0,1)
SetGadgetItemState(10,0, #PB_Tree_Expanded )
DisableGadget(20,1)
DisableGadget(21,0)
Case 21
RemoveGadgetItem(10,4)
DisableGadget(21,1)
DisableGadget(22,0)
Case 22
End
Default
MessageRequester("GadgetID", Str(GadgetID))
EndSelect
Case #PB_Event_CloseWindow
Quit=1
EndSelect
Until quit=1
Ensuite cliquez sur chq item de l'arbre : pas de problème !
Ensuite cliquez sur le deuxième bouton :
Ensuite cliquez sur chq item de l'arbre : problème au dernier item : il a gardé son state d'origine !