How to Paint a Form before it is displayed?
Posted on 2004-08-31
I am creating a Form that does an animation when it appears. I need to Paint the text on the Form before it is displayed.
I tried using the Form Paint event to paint the text, but the text is not displayed until the animation stops. Here is my code so far:
Dim f2 As New Form2
Dim g As Graphics = f2.CreateGraphics
Dim myfont As New Font("Microsoft Sans Serif", 9.5)
Dim sTxt As String = "This is some text"
Dim rec As New RectangleF
rec.Height = 50
rec.Width = 270
rec.X = 50
rec.Y = 28
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Near
Dim mybrush2 As New SolidBrush(Color.White)
g.DrawString(sTxt, myfont, mybrush2, rec, sf)
AnimateWindow(f2.Handle, 300, AnimateWindowFlags.AW_VER_NEGATIVE Or AnimateWindowFlags.AW_SLIDE)
Thanks for any ideas