Imports System.Text _used for string manipulations
Imports System.Xml _ used for XML reading
Public Class NewsTicker
Inherits System.Windows.Forms.Form
Dim widthX As Single
Dim heightY As Single = 0
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 NewsTicker_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()
Dim gr As Graphics
Timer1.Interval = 100
Timer1.Start()
fo = New Font("Times New Roman", 14, FontStyle.Bold, GraphicsUnit.Point)
strwidth = g.MeasureString(str, fo)
douX = strwidth.Width
End Sub
Private Sub loadthenews()
Dim readXML As New XmlTextReader("G:vbappsdr
ews.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.Black, widthX, heightY)
_ Debug.Write(String.Format("the string width is {0}", CStr(strwidth.Width)))
If widthX <= (0 - douX) Then
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 MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Application.Exit()
End Sub
End Class