I need to get rid of a flickering that happens everytime my scrolling text appears. If anyone can help me it will be great. Here's the code of the form:
Public Class ticker
Inherits System.Windows.Forms.Form
Dim S As New setup
Dim widthX As Single
Dim heightY As Single = 3
Dim g As Graphics
Dim xmlst As String 'string from the xml file
Dim fo As Font
Dim str As String
Dim strwidth As SizeF 'gets the xml string's width and height
Dim douX As Double 'stores the xmlstring's width
Private Sub ticker_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
g = Me.CreateGraphics() 'get the graphics object of the form
widthX = Me.Width ' x co- ordinate or width
' Debug.Write(String.Format("The width is {0}", ‘CStr(Me.Width)))
Me.loadthenews()
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.UpdateStyles()
Dim gr As Graphics
Timer1.Interval = 75
Timer1.Start()
fo = New Font("Arial Narrow", 18, FontStyle.Italic, GraphicsUnit.Point)
strwidth = g.MeasureString(str, fo)
douX = strwidth.Width
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.UpdateStyles()
End Sub
Private Sub loadthenews()
Dim readXML As New XmlTextReader("http://www.betstreetsmart.com/sports.xml")
While readXML.Read()
If readXML.NodeType = XmlNodeType.Text Then
str += " " & readXML.Value
End If
End While
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'Debug.Write(vbCr & strwidth.Width & vbCr)
'Debug.Write(String.Format("widthX = {0}", CStr(widthX) & vbCr))
g.Clear(Me.BackColor)
g.DrawString(str, fo, Brushes.White, widthX, heightY)
' Debug.Write(String.Format("the string width is {0}", ‘
' CStr(strwidth.Width)))
If widthX <= (0 - douX) Then 'check whether all text ‘have been scrolled
widthX = Me.Width
Else
widthX -= 5
End If
End Sub
Private Sub NewsTicker_hover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseHover
Timer1.Stop()
Debug.Write(String.Format("The string width is {0}", CStr(douX)))
End Sub
Private Sub NewsTicker_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave
Timer1.Start()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
System.Diagnostics.Process.Start("www.sportscallcenter.com")
End Sub
Private Sub ticker_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
System.Diagnostics.Process.Start("www.betandclick.com/form.htm")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Static CustomColors() As Integer = {RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255)}
'initializing CustomColors with an array of integers and putting Red, Green,
'and Blue in the custom colors section
Try
With ColorDialog1
.Color = BackColor
'initializing the selected color to match the color currently used
'by the richtextbox's foreground color
.CustomColors = CustomColors
'filling custom colors on the dialog box with the array declared above
If .ShowDialog() = DialogResult.OK Then
BackColor = .Color
CustomColors = .CustomColors
'Storing the custom colors to use again
End If
ColorDialog1.Reset()
'resetting all colors in the dialog box
End With
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Timer1.Interval = Me.Timer1.Interval - 10
If (Me.Timer1.Interval <= 10) Then
Me.Timer1.Interval = 100
End If
End Sub
End Class
Public Class ticker
Inherits System.Windows.Forms.Form
Dim S As New setup
Dim widthX As Single
Dim heightY As Single = 3
Dim g As Graphics
Dim xmlst As String 'string from the xml file
Dim fo As Font
Dim str As String
Dim strwidth As SizeF 'gets the xml string's width and height
Dim douX As Double 'stores the xmlstring's width
Private Sub ticker_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
g = Me.CreateGraphics() 'get the graphics object of the form
widthX = Me.Width ' x co- ordinate or width
' Debug.Write(String.Format("The width is {0}", ‘CStr(Me.Width)))
Me.loadthenews()
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.UpdateStyles()
Dim gr As Graphics
Timer1.Interval = 75
Timer1.Start()
fo = New Font("Arial Narrow", 18, FontStyle.Italic, GraphicsUnit.Point)
strwidth = g.MeasureString(str, fo)
douX = strwidth.Width
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.UpdateStyles()
End Sub
Private Sub loadthenews()
Dim readXML As New XmlTextReader("http://www.betstreetsmart.com/sports.xml")
While readXML.Read()
If readXML.NodeType = XmlNodeType.Text Then
str += " " & readXML.Value
End If
End While
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'Debug.Write(vbCr & strwidth.Width & vbCr)
'Debug.Write(String.Format("widthX = {0}", CStr(widthX) & vbCr))
g.Clear(Me.BackColor)
g.DrawString(str, fo, Brushes.White, widthX, heightY)
' Debug.Write(String.Format("the string width is {0}", ‘
' CStr(strwidth.Width)))
If widthX <= (0 - douX) Then 'check whether all text ‘have been scrolled
widthX = Me.Width
Else
widthX -= 5
End If
End Sub
Private Sub NewsTicker_hover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseHover
Timer1.Stop()
Debug.Write(String.Format("The string width is {0}", CStr(douX)))
End Sub
Private Sub NewsTicker_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave
Timer1.Start()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
System.Diagnostics.Process.Start("www.sportscallcenter.com")
End Sub
Private Sub ticker_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
System.Diagnostics.Process.Start("www.betandclick.com/form.htm")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Static CustomColors() As Integer = {RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255)}
'initializing CustomColors with an array of integers and putting Red, Green,
'and Blue in the custom colors section
Try
With ColorDialog1
.Color = BackColor
'initializing the selected color to match the color currently used
'by the richtextbox's foreground color
.CustomColors = CustomColors
'filling custom colors on the dialog box with the array declared above
If .ShowDialog() = DialogResult.OK Then
BackColor = .Color
CustomColors = .CustomColors
'Storing the custom colors to use again
End If
ColorDialog1.Reset()
'resetting all colors in the dialog box
End With
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Timer1.Interval = Me.Timer1.Interval - 10
If (Me.Timer1.Interval <= 10) Then
Me.Timer1.Interval = 100
End If
End Sub
End Class