
Code : Tout sélectionner
Procedure ThreadMarqueeTextGadget(ID)
GadText.s = GetGadgetText(ID)
LenTxt.l = Len(GadText)
GadWidth = GadgetWidth(ID)
DisableDebugger
Boucle :
For k = 1 To GadWidth*0.25-LenTxt
SetGadgetText(ID, Space(k)+GadText)
Delay(100)
Next k
For k = GadWidth*0.25-LenTxt To 1 Step -1
SetGadgetText(ID, Space(k)+GadText)
Delay(100)
Next k
Goto Boucle
EnableDebugger
EndProcedure
Procedure MarqueeTextGadget(ID, x, y, Width, Heigth, Text$)
TextGadget(ID, x, y, Width, Heigth, Text$)
TID = CreateThread(@ThreadMarqueeTextGadget(), ID)
If TID = 0
FreeGadget(ID)
EndIf
ProcedureReturn TID
EndProcedure
Procedure SetMarqueeTextGadgetText(ID, TID, Text$)
KillThread(TID)
SetGadgetText(ID, Text$)
TID = CreateThread(@ThreadMarqueeTextGadget(), ID)
If TID = 0
FreeGadget(ID)
EndIf
ProcedureReturn TID
EndProcedure
Procedure FreeMarqueeTextGadget(ID, TID)
KillThread(TID)
FreeGadget(ID)
EndProcedure
If OpenWindow(0, 0, 0, 100, 100, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "test")
If CreateGadgetList(WindowID(0))
MGad = MarqueeTextGadget(1, 0, 0, 100, 15, "Gadget test !")
MGad2 = MarqueeTextGadget(3, 0, 20, 100, 15, "Gadget test !")
MGad2 = SetMarqueeTextGadgetText(3, MGad2, "Gadget test 2 !")
ButtonGadget(2, 10, 45, 90, 20, "Free (1)")
EndIf
Repeat
Event = WindowEvent()
If Event = #PB_EventGadget
GadgetID = EventGadgetID()
If GadgetID = 2
FreeMarqueeTextGadget(1, MGad)
DisableGadget(2, 1)
EndIf
EndIf
Until Event = #PB_EventCloseWindow
EndIf