My last 2 cents
Tested with PB 5.73 x86 - Windows 10 x64
# 1: Using Windows CallBack
Code: Select all
Global x
x = 0
Procedure WndProc(hwnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_TIMER
x - 1
If x = -380
x = 380
EndIf
ResizeGadget(1,x,0,380,75)
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(0),0,0)
StopDrawing()
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 0, 0, 400, 130, "Scroller", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SmartWindowRefresh(0,1)
LoadFont(0, "Georgia" , 32)
ContainerGadget(0,10,10,380,75,#PB_Container_Flat)
SetGadgetColor(0,#PB_Gadget_BackColor,0)
CanvasGadget(1,0,0,380,80)
CloseGadgetList()
DisableGadget(0,1)
text.s = " .... Scroll Text .... "
CreateImage(0,380,80,24,0)
StartDrawing(ImageOutput(0))
DrawingFont(FontID(0))
DrawingMode(#PB_2DDrawing_AlphaBlend | #PB_2DDrawing_Transparent )
pos = DrawText(0,6,".... ",$4DFE3A |$FF000000)
pos = DrawText(pos,6,"Scrolling ",$FE785D |$FF000000)
pos = DrawText(pos,6,"Text ",$5D80FE |$FF000000)
DrawText(pos,6,"....",$16E200 |$FF000000)
StopDrawing()
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(0),0,0)
StopDrawing()
ButtonGadget(2,10,98,40,24,"ON",#PB_Button_Toggle)
SetWindowCallback(@WndProc())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 2
If GetGadgetState(2) = 1
SetGadgetText(2,"OFF")
SetTimer_(WindowID(0),125,10,0)
Else
SetGadgetText(2,"ON")
KillTimer_(WindowID(0),125)
x = 0
ResizeGadget(1,x,0,380,75)
EndIf
EndSelect
EndSelect
Until Quit = 1
# 2: Using BindEvent
Code: Select all
Global x
x = 0
Procedure scrollTEXT()
x - 1
If x = -380
x = 380
EndIf
ResizeGadget(1,x,0,380,75)
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(0),0,0)
StopDrawing()
EndProcedure
OpenWindow(0, 0, 0, 400, 130, "Scroller", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SmartWindowRefresh(0,1)
LoadFont(0, "Georgia" , 32)
ContainerGadget(0,10,10,380,75,#PB_Container_Flat)
SetGadgetColor(0,#PB_Gadget_BackColor,0)
CanvasGadget(1,0,0,380,80)
CloseGadgetList()
DisableGadget(0,1)
text.s = " .... Scroll Text .... "
CreateImage(0,380,80,24,0)
StartDrawing(ImageOutput(0))
DrawingFont(FontID(0))
DrawingMode(#PB_2DDrawing_AlphaBlend | #PB_2DDrawing_Transparent )
pos = DrawText(0,6,".... ",$4DFE3A |$FF000000)
pos = DrawText(pos,6,"Scrolling ",$FE785D |$FF000000)
pos = DrawText(pos,6,"Text ",$5D80FE |$FF000000)
DrawText(pos,6,"....",$16E200 |$FF000000)
StopDrawing()
StartDrawing(CanvasOutput(1))
DrawImage(ImageID(0),0,0)
StopDrawing()
ButtonGadget(2,10,96,45,25,"ON",#PB_Button_Toggle)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 2
If GetGadgetState(2) = 1
SetGadgetText(2,"OFF")
;SetTimer_(WindowID(0),125,10,0)
AddWindowTimer(0,125,10)
BindEvent(#PB_Event_Timer,@scrollTEXT())
Else
SetGadgetText(2,"ON")
;KillTimer_(WindowID(0),125)
RemoveWindowTimer(0,125)
x = 0
ResizeGadget(1,x,0,380,75)
UnbindEvent(#PB_Event_Timer,@scrollTEXT())
EndIf
EndSelect
EndSelect
Until Quit = 1
# 3: Using Thread
Code: Select all
Global x,onflag
Procedure scrolltext(par)
Repeat
For t = 0 To 500
x - 1
If IsGadget(1)
MoveWindow_(GadgetID(1),x,10,380,70,1)
EndIf
Next
Delay(1000)
For t = 0 To 550
x - 1
If IsGadget(1)
MoveWindow_(GadgetID(1),x,10,380,70,1)
EndIf
Next
Delay(1000)
x = 700
Until onflag = 0
EndProcedure
chk = 16
CreateImage(10, chk*2,chk*2)
StartDrawing(ImageOutput(10))
Box(0,0,chk,chk,$4BE0FE)
Box(chk,0,chk,chk,$CFFEE7)
Box(0,chk,chk,chk,$CFFEE7)
Box(chk,chk,chk,chk,$4BE0FE)
StopDrawing()
hBrush = CreatePatternBrush_(ImageID(10))
OpenWindow(0, 0, 0, 800, 130, "Scroller", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SmartWindowRefresh(0,1)
LoadFont(0, "Georgia" , 32)
ContainerGadget(0,10,10,780,75,#PB_Container_Flat)
SetClassLongPtr_(GadgetID(0), #GCL_HBRBACKGROUND, hBrush)
ImageGadget(1,700,12,780,70,0)
CloseGadgetList()
DisableGadget(0,1)
text.s = " .... Scroll Text .... "
CreateImage(0,390,70,32,#PB_Image_Transparent)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend | #PB_2DDrawing_Transparent)
DrawingFont(FontID(0))
color = ($E2E2E2|$FF000000)
DrawText(6,2,text,color)
color = ($000000|$FF000000)
DrawText(8,4,text,color)
color = ($959595|$FF000000)
DrawText(7,3,text,color)
StopDrawing()
SetGadgetState(1,ImageID(0))
ButtonGadget(2,10,96,45,25,"ON",#PB_Button_Toggle)
x = 700
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 2
If GetGadgetState(2) = 1
onflag = 1
SetGadgetText(2,"OFF")
thread = CreateThread(@scrolltext(),30)
Else
SetGadgetText(2,"ON")
onflag = 0
EndIf
EndSelect
EndSelect
Until Quit = 1