Hi all, am having a problem with a news ticker xml reader, when the windows form read the english xml and view it in label all ok, but when reading the arabic xml and view it in windows form label the CPU goes to %50, is this a unicode problem or what.
here is the code
Imports System.Xml
Imports System.Threading
Imports System.Text.UTF8Encoding
Friend Class arabic
Inherits System.Windows.Forms.Form
Private warningopacity As Boolean
Private surfaceround As Boolean
Dim str As String
Private Declare Function ReleaseCapture Lib "user32" () As Integer
Private Const HTCAPTION As Integer = 2
Private Const WM_NCLBUTTONDOWN As Integer = &HA1S
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Width = Int((Screen.PrimaryScreen.WorkingArea.Width) * (1%))
Me.SetDesktopLocation(1, 680)
warningopacity = True
surfaceround = False
HScrollBar1.Visible = False
End Sub
Private Sub NewsTicker_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.loadthenews()
Label1.Text = str
Me.SetStyle(ControlStyles.UserPaint, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.DoubleBuffer, True)
SetStyle(ControlStyles.UserPaint, True)
Me.UpdateStyles()
Label1.BackColor = Me.BackColor
Panel1.BackColor = Me.BackColor
Label1.AutoSize = True
Label1.Left = Panel1.Width
Timer1.Interval = 10
Timer1.Start()
End Sub
Private Sub loadthenews()
Try
str = vbNullString
Dim readXML As New XmlTextReader("http://arabic.pnn.ps/templates/aticker-jo/fticker.xml")
While readXML.Read()
If readXML.NodeType = XmlNodeType.Text Then
str += " " & readXML.Value & " "
End If
End While
Catch exW As System.Net.WebException
MessageBox.Show("Feed is Temporarly Unavailable")
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Left += 1
If Label1.Left > Panel1.Width Then
Label1.Left = -Label1.Width
Label1.Text = str
Me.Timer1.Stop()
Dim t As New Thread(AddressOf loadthenews)
t.Start()
Me.Timer1.Start()
End If
End Sub
Private Sub Mouseon(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.MouseHover
Me.Timer1.Stop()
ToolTip1.Show("Right Click For Options", Label1, 5000)
End Sub
Private Sub Mouse_Exit(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.MouseLeave
ToolTip1.Hide(Label1)
Me.Timer1.Start()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
AboutBox1.Show()
End Sub
Private Sub MinimizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinimizeToolStripMenuItem.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub ColorsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorsToolStripMenuItem.Click
Style.Show()
End Sub
Private Sub YesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YesToolStripMenuItem.Click
Me.TopMost = True
End Sub
Private Sub NoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NoToolStripMenuItem.Click
Me.TopMost = False
End Sub
Private Sub LanguageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LanguagesToolStripMenuItem.Click
urlanguage.Show()
Me.Close()
End Sub
Private Sub panel1_MousedoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDoubleClick
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedToolWindow
End Sub
Private Sub panel1_mouseclick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseClick
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End Sub
Private Sub panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
ReleaseCapture()
SendMessage(Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
ReleaseCapture()
SendMessage(Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
Me.Opacity = HScrollBar1.Value / 100
If HScrollBar1.Value <= 30 And warningopacity = True Then
MessageBox.Show("WARNING: The form will not be visible if the opacity is set to minimum. The scrollbar will not be visible.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
warningopacity = False
ElseIf HScrollBar1.Value > 30 Then
warningopacity = True
End If
End Sub
Private Sub VisibleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowBarToolStripMenuItem.Click
HScrollBar1.Visible = True
End Sub
Private Sub HideBarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideBarToolStripMenuItem.Click
HScrollBar1.Visible = False
End Sub
End Class