Restored from previous forum. Originally posted by boop64.
This is a small sample that will provide the effect of a scrolling text gadget... Let me know what you think ^_^
----------Start Code-----------
;Scroll Text ~ By Boop64
;----Constants
#MainWnd = 1
#ScrollText = 1
;----Globals
Global ftext.s, fi
ftext.s = "Here is some scrolling text..............^_^" ;Make sure your text dose not end up wider than the window
;----Procedures
Procedure scroll() ;Scroll the text accross the screen
ResizeGadget(#ScrollText, fi, 0, Len(ftext)*5, 15)
If fi < -Len(ftext)*4 ;Aproximate the position of the when it is completely out of view on the left side of the window
fi = WindowWidth() ;Reset the text position so that it comes from the right side of the window
EndIf
fi = fi -1 ;Make the text scroll from right to left
EndProcedure
If OpenWindow( #MainWnd, 0,0,300,20, #PB_Window_SystemMenu | #PB_Window_ScreenCentered,"Scroll")
If CreateGadgetList(WindowID(1))
TextGadget(#ScrollText,0,0, Len(ftext)*5,16, ftext)
EndIf
StartTimer(1,100,@scroll()) ;Set a timer at the appropriate interval so that the text will scroll smoothly.
Repeat
Delay(1)
EventID.l = WaitWindowEvent()
Select EventID
Case #PB_EventCloseWindow
quit = 1
EndSelect
Until Quit = 1
;Kills the timer
EndTimer(1)
;Move the text to a position that is NOT outside of the window so that we don't get any errors when we close the program
ResizeGadget(#ScrollText, 0, 0, Len(ftext)*5, 15)
EndIf
End
----------End Code-----------
Regards, John
Happy coding ^_^
