Click to See Complete Forum and Search --> : AutoRedraw = True?


makai
November 28th, 2002, 01:26 PM
Is there a .Net equivalent for AutoRedraw = True?

this is the code that does not work if you minimize the form and restore


Public Class Form1
Inherits System.Windows.Forms.Form

Private b1 As Bitmap

Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
Me.Text = "AutoRedraw Test"
Me.BackColor = System.Drawing.Color.White

FormPrint(".NET Printing", 10, 10)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FormPrint("2nd Printing", 100, 100)
End Sub

Private Sub FormPrint(ByVal t$, ByVal x1%, ByVal y1%)
Dim g1 As Graphics = Me.CreateGraphics()

System.Windows.Forms.Application.DoEvents()

g1.DrawString(t, New Font("Verdana", 12), _
Brushes.Black, x1, y1)

System.Windows.Forms.Application.DoEvents()

b1 = New Bitmap(Me.Size.Width, Me.Size.Height, g1)
End Sub

' Redraw the form.
Private Sub Form1_Paint( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint

If Not (b1 Is Nothing) Then e.Graphics.DrawImage(b1, 0, 0)
End Sub
End Class


the theory is simple - create a bitmap of the form with each text write and then copy that bitmap back to the form in the Paint event - evidently I do not understand the graphics methods - can anyone help?

WillemM
November 29th, 2002, 11:26 AM
Yes take a look at the properties in the properties-window.
There must be a property that does this for you. I don't know the name, but I know that there is.

makai
November 29th, 2002, 03:16 PM
no - I guarantee you there is no such property in VB .NET

WillemM
November 30th, 2002, 04:29 AM
I'm home now, I will find something for you that can help you solve this problem