Hello. Here's a simple slice of code that isn't doing what I'd expect! It should be flickerless - because I've 'turned on' the Form's double-buffering. Does anyone know why it isn't working?
There's a thin line between genius, and insanity!
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call EnableDoubleBuffering()
End Sub
Private Sub EnableDoubleBuffering()
Me.SetStyle(ControlStyles.DoubleBuffer _
Or ControlStyles.UserPaint _
Or ControlStyles.AllPaintingInWmPaint, _
True)
Me.UpdateStyles()
End Sub
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
Dim gSurface As Graphics = Me.CreateGraphics
Dim sz As Single = 24.0
Dim s As String = "Let 'em SPIN!"
Dim f As New Font(New FontFamily("Arial Black"), sz)
Dim b As New SolidBrush(Color.Black)
Dim x As Int32 = 0
Dim y As Int32 = 0
Dim iLoop As Int32 = 0
Do While iLoop < 50
iLoop += 1
x += 1
y += 1
gSurface.Clear(Me.BackColor)
gSurface.DrawString(s, f, b, x, y)
System.Threading.Thread.Sleep(10)
Loop
iLoop = 0
x = 0
y = 0
f.Dispose()
b.Dispose()
End Sub
There's a thin line between genius, and insanity!