Persisting Graphics{Resolved}
I have a project I've been working on and it consists of working with graphics.
The only problem I have is when the graphics show up on the form; if I minimize it or another window comes over top of my projects form, it erases the graphics.
I know I might of not explained this well enough or it might not make sense but I'm not sure how to explain it. So Can anyone please give me a solution?
Also I posted in the other forum and got an answer in VB6 when i need it in VB.NET
anyways they said that the auto redraw property of the form should be set to true.
What would the auto redraw property of a form be in VB.NET?
Re: Persisting Graphics{Resolved}
Quote:
Draw the graphics onto a bitmap object. And then set the form's image property = the bitmap.
got samples?
man, I got the same problem, me brain's about to blow!
:confused:
edit: got everything fixed up... but I don't have as much flexibility over doing graphics...
can't draw a string directly to the bitmap... :(
Re: Persisting Graphics{Resolved}
VB Code:
Dim bm As New Bitmap(Me.Size.Width, Me.Size.Height)
Dim gr As Graphics
gr = Graphics.FromImage(bm)
gr.FillRectangle(SystemBrushes.Control, 0, 0, Me.Size.Width, Me.Size.Height)
gr.DrawEllipse(Pens.Black, 0, 0, 100, 50)
Me.BackgroundImage = bm
The fillREct is there so you don't have a transparent background on repaint..
Bill
Re: Persisting Graphics{Resolved}
Quote:
Originally Posted by Ruku
can't draw a string directly to the bitmap... :(
Wouldn't you just call the DrawString method of the Graphics object?
Re: Persisting Graphics{Resolved}
He's right, the DrawString method will do just that, however, if you are wanting the app to have the look and feel of the rest of the OS, you can run into much more code. You'll need to take into consideration the size and style of fonts being used by the user in order to do this well. You can get the font as easily as using Me.Font inside your form class, and the dimensions of the finished product by using the MeasureString method, though some have mentioned certain characters don't measure correctly.
Bill
Re: Persisting Graphics{Resolved}
yeah, I got everything fixed up! I figured how to use the graphics object onto the bitmap object... :wave: