07-09-19, 06:51 PM
السلام عليكم
هذا هو الحل
كلاس جديد ثم Run
وبعدها أضف الاداة من Toolsbox
للامانة الحل ليس من عندي فقط نقلته لكم
وهذا هو الرابط
https://www.dev-point.com/vb/threads/696536/
هذا هو الحل
كلاس جديد ثم Run
كود :
Public Class Class1
Inherits Control
Public texts As String() = Nothing
Private text_ As String = Nothing
Private point As New Point(0, 0)
Private tTimer As System.Timers.Timer = Nothing
Private index As Integer = -1
Protected Overrides Sub OnPaint(e As PaintEventArgs)
MyBase.OnPaint(e)
Dim g As Graphics = e.Graphics
With g
.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
Me.Font = Font
Me.ForeColor = ForeColor
Dim bol As Boolean = point.X < Me.Width
If texts IsNot Nothing And tTimer IsNot Nothing Then
If text_ Is Nothing Then
'عشوائي
'Dim rnd As Random = New Random
'text_ = texts(rnd.Next(0, texts.Length))
'بترتيب
index = If(index >= texts.Length - 1, 0, index + 1)
text_ = texts(index)
End If
Dim sizeString As New SizeF(.MeasureString(text_, Me.Font))
If bol Then
point.X += 1
'السرعة
'point.X += 5
Else
point.X = -sizeString.Width
text_ = Nothing
End If
.DrawString(text_, Me.Font, New SolidBrush(Me.ForeColor), point.X, 0)
End If
End With
End Sub
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
Me.DoubleBuffered = True
Me.Size = New System.Drawing.Size(200, 50)
Me.BackColor = Color.Transparent
Me.Font = Font
Me.ForeColor = ForeColor
End Sub
Public Sub StartTimer()
index = -1
tTimer = New System.Timers.Timer
AddHandler tTimer.Elapsed, AddressOf OnTimedEvent
tTimer.Interval = 10
tTimer.AutoReset = True
tTimer.Enabled = True
End Sub
Public Sub StopTimer()
If tTimer IsNot Nothing Then
tTimer.Stop()
tTimer.Enabled = False
tTimer.Dispose()
tTimer = Nothing
Invalidate()
End If
End Sub
Private Sub OnTimedEvent(source As Object, e As Timers.ElapsedEventArgs)
Invalidate()
End Sub
End Class
كود :
Class11.texts = {"text1", "text2", "text3"}
Class11.StartTimer()
'Class11.StopTimer()
للامانة الحل ليس من عندي فقط نقلته لكم
وهذا هو الرابط
https://www.dev-point.com/vb/threads/696536/
اعمل الخير وأجرك لا تنتظره فالله خير من إليك يرده
البرمجة ليست مجرد كود بل هي منهج تفكير منطقي لحل المشكلات