Far scorrere un testo in una DrawingArea
Da Gambas-it.org - Wikipedia.
Versione del 21 lug 2023 alle 11:10 di Vuott (Discussione | contributi)
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 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1" .Font.Size = 24 c = -.Font.TextWidth(TESTO) End With End Public Sub Form_Open() With tmp = New Timer As "TMP" .Delay = VELOX .Start End With End Public Sub TMP_Timer() Inc c With DrawingArea1 If c == .W Then c = -.Font.TextWidth(TESTO) .Refresh End With End Public Sub DrawingArea1_Draw() With Paint .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 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1" .Font.Size = 24 End With 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 If c < -.TextSize(TESTO).W Then c = DrawingArea1.W .DrawText(TESTO, c, (DrawingArea1.H / 2) - (.TextSize(TESTO).H / 2)) .End End With End