Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double-buffering not working

Status
Not open for further replies.

T0AD

Programmer
Jun 4, 2003
73
GB
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?

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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top