Far scorrere un testo in una DrawingArea

Da Gambas-it.org - Wikipedia.

Far scorrere un testo da sinistra verso destra

Private DrawingArea1 As DrawingArea
Private Const VELOX As Short = 10
Private Const TESTO As String = "Testo qualsiasi"
Private tmp As Timer
Private c As Short


Public Sub _new()

 With Me
   .W = Screen.AvailableWidth
   .H = Screen.AvailableHeight
   .Arrangement = Arrange.Fill
 End With

 DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"

End


Public Sub Form_Open()

 With tmp = New Timer As "TMP"
   .Delay = VELOX
   .Start
 End With

End


Public Sub TMP_Timer()
 
 Inc c
 If c == DrawingArea1.W Then c = 0

 DrawingArea1.Refresh

End


Public Sub DrawingArea1_Draw()

 With Paint
   .Font.Size = 24
   .DrawText(TESTO, c, (DrawingArea1.H / 2) - (.TextSize(TESTO).H / 2))
   .End
 End With

End

Far scorrere il testo da destra verso sinistra

Private DrawingArea1 As DrawingArea
Private Const VELOX As Short = 10
Private Const TESTO As String = "Testo qualsiasi"
Private tmp As Timer
Private c As Short


Public Sub _new()

 With Me
   .W = Screen.AvailableWidth
   .H = Screen.AvailableHeight
   .Arrangement = Arrange.Fill
 End With

 DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"

End


Public Sub Form_Arrange()

 c = DrawingArea1.W

 With tmp = New Timer As "TMP"
   .Delay = VELOX
   .Start
 End With

End


Public Sub TMP_Timer()

 DrawingArea1.Refresh

 Dec c

End


Public Sub DrawingArea1_Draw()

 With Paint
   .Font.Size = 24
   If c < -.TextSize(TESTO).W Then c = DrawingArea1.W
   .DrawText(TESTO, c, (DrawingArea1.H / 2) - (.TextSize(TESTO).H / 2))
   .End
 End With

End