Je suis content que ton code serve.
Je serai toi, je créerai un générateur de bouton.
ça ce serai vraiment utile. Un code trop long est moins facilement exploitable qu'un soft qui va générer un bouton selon des options.
J'en ai esquissé un vite fait. C'est pour l'exemple.
Code : Tout sélectionner
; Canvas button créator exemple.
; Ar-S : PB 5.60 x64
Declare.s Generate()
Declare exit()
Declare Owin()
Enumeration
#Win
#Panel
; textes
#T_Button_L
#T_Button_H
#T_Button_X
#T_Button_Y
#T_Button_ID
#T_Button_Text
; strings
#BT_X
#BT_Y
#BT_L
#BT_H
#BT_TXT
#BT_ID
#GENERATE
#CANVAS
EndEnumeration
Procedure exit()
End
EndProcedure
Procedure.s Generate()
IDbt.s = GetGadgetText(#BT_ID)
Xbt.s = GetGadgetText(#BT_X)
Ybt.s = GetGadgetText(#BT_Y)
Lbt.s = GetGadgetText(#BT_L)
Hbt.s = GetGadgetText(#BT_H)
Nbt.s = GetGadgetText(#BT_TXT)
Code.s = "CanvasGadget("+IDbt+", " + Xbt + ", "+ Ybt+ ", " + Lbt+", "+Hbt+")"
;exemple
MessageRequester("test","Code du bouton"+Chr(10)+Code)
ProcedureReturn Code.s
EndProcedure
Procedure Owin()
OpenWindow(#win,#PB_Ignore,#PB_Ignore,800,600,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
PanelGadget(#Panel,1,1,798,598)
AddGadgetItem(#Panel, -1, "Edition")
TextGadget(#T_Button_X, 5, 10, 145, 20, "Position X dans fenêtre :", #SS_CENTERIMAGE)
TextGadget(#T_Button_Y, 5, 35, 145, 20, "Position Y dans fenêtre :", #SS_CENTERIMAGE)
TextGadget(#T_Button_L, 5, 60, 145, 20, "Largeur du bouton :", #SS_CENTERIMAGE)
TextGadget(#T_Button_H, 5, 85, 145, 20, "Hauteur du bouton :", #SS_CENTERIMAGE)
TextGadget(#T_Button_ID, 5, 110, 145, 20, "ID du bouton : ", #SS_CENTERIMAGE)
TextGadget(#T_Button_Text,5, 135, 145, 20, "Texte du bouton :", #SS_CENTERIMAGE)
StringGadget(#BT_X, 153, 13, 45, 20, "0", #PB_String_Numeric)
StringGadget(#BT_Y, 153, 38, 45, 20, "0", #PB_String_Numeric)
StringGadget(#BT_L, 153, 63, 45, 20, "", #PB_String_Numeric)
StringGadget(#BT_H, 153, 88, 45, 20, "", #PB_String_Numeric)
StringGadget(#BT_TXT, 153, 138, 151, 20, "Je suis un bouton", #PB_String_Numeric)
StringGadget(#BT_ID, 153, 113, 70, 20, "#Button_01")
ButtonGadget(#GENERATE, 5,200,250,50,"Générer")
CanvasGadget(#CANVAS,0,260,100,50)
AddGadgetItem (#Panel, -1, "Code généré")
BindEvent(#PB_Event_CloseWindow, @Exit() )
EndProcedure
Owin()
Repeat
WaitWindowEvent()
If Event() = #PB_Event_Gadget And EventGadget() = #GENERATE
Generate()
EndIf
ForEver