Greetings!
I am developping a multiple forms Windows Forms application in Visual
Studio C++ .NET 2003 and I need to draw graphics into a group box. In
order to do this I use:
private: System::Void button1_Click(System::Object * sender,
System::EventArgs * e) {
Graphics* graph= Graphics::FromHwnd(this->groupBox1->Handle);
graph->DrawLine(new Pen(Color::Blue),20,20,50,50);//whatever...
}
It works. But the problem is: when I minimize and maximize again the
window, or when I put any window over my graphic, it vanishes! What
could I do in order to make the graphics stable?
If anybody could help anyway, I thank very much
Garry Freemyer - 07 Jun 2005 16:54 GMT
Ok, basically, you need to do your graphics in a paint event. When you don't
do them in paint events or don't call your drawing stuff from paint events,
your graphics vanish, but since windows expects the programmer to put the
drawing stuff in the paint event in events where it needs to be redrawn,
your stuff vanishes.
Check out Bob Powell's excellent FAQ site on GDI+ graphics. It has a lot of
nice info there ...
http://www.bobpowell.net/faqmain.htm
> Greetings!
> I am developping a multiple forms Windows Forms application in Visual
[quoted text clipped - 11 lines]
> could I do in order to make the graphics stable?
> If anybody could help anyway, I thank very much
Marcelo - 08 Jun 2005 08:37 GMT
Thank you very much! And the FAQ site is really very good. Now in my
favourites :o)
Marcelo Schio