Declare AjouteGadget(No, x, y, width, height, texte.s)
If OpenWindow(0, 100, 200, 200, 200, "Ajout gadgets")
If CreateGadgetList(WindowID(0))
ButtonGadget(0, 0, 0, 100, 100, "Bouton 0")
EndIf
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
ElseIf EventID = #PB_Event_Gadget
Select EventGadget()
Case 0
AjouteGadget(1, 100, 100, 100, 100, "Bouton 1")
Case 1
If IsGadget(2)=0
AjouteGadget(2, 0, 100, 100, 100, "Bouton 2")
EndIf
EndSelect
EndIf
Until Quit = 1
EndIf
Procedure AjouteGadget(No, x, y, width, height, texte.s)
If OpenGadgetList(0)
ButtonGadget(No, x, y, width, height, texte)
EndIf
EndProcedure