jari_stockholm
New member
- Joined
- May 4, 2009
- Messages
- 2
Hi There
Anyone got a idea how to get rid of the flickering?
Yes, complete source code is pasted also.
copy and paste the code and RUN it.
now move the mouse up and down...
Anyone got a idea how to get rid of the flickering?
Yes, complete source code is pasted also.
copy and paste the code and RUN it.
now move the mouse up and down...
Code:
Option Explicit On
Public Class Form1
Dim iLine As Integer
Dim iTab As Integer
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim myGraphics As Graphics = MyBase.CreateGraphics()
Dim myPen As New Pen(Color.FromArgb(45, 45, 45))
Dim myBrush As New SolidBrush(Color.FromArgb(230, 230, 230))
Dim myBrush2 As New SolidBrush(Color.FromArgb(80, 80, 80))
Dim g As Graphics = e.Graphics
[1] Draw the rectangle behind text line
myGraphics.FillRectangle(myBrush, iTab, iLine, 300, 20)
[2] Draw 20 lines with some text
For i = 0 To 20
g.DrawString("Textline_" & (i), New Font("Verdena", 12), myBrush2, iTab, i * 20)
Next i
MyBase.OnPaint(e)
End Sub
Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
iline is used to -> Dont update screen while mouse at same line as last time
my idea to avoid unnessesary screen updates
Select Case e.Y
Case 0 To 19 And iLine <> 0
iLine = 0
Me.Invalidate()
Case 20 To 39 And iLine <> 20
iLine = 20
Me.Invalidate()
Case 40 To 59 And iLine <> 40
iLine = 40
Me.Invalidate()
Case 60 To 79 And iLine <> 60
iLine = 60
Me.Invalidate()
Case 80 To 99 And iLine <> 80
iLine = 80
Me.Invalidate()
Case 100 To 119 And iLine <> 100
iLine = 100
Me.Invalidate()
Case 120 To 139 And iLine <> 120
iLine = 120
Me.Invalidate()
Case 140 To 159 And iLine <> 140
iLine = 140
Me.Invalidate()
Case 160 To 179 And iLine <> 160
iLine = 160
Me.Invalidate()
Case 180 To 199 And iLine <> 180
iLine = 180
Me.Invalidate()
End Select
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Last edited by a moderator: