Home > Archive > Visual Studio > June 2005 > Graphics Vanish when Window is Over
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Graphics Vanish when Window is Over
|
|
| Marcelo 2005-06-07, 8:59 am |
| 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 2005-06-07, 4:02 pm |
| 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
"Marcelo" <marschio@msn.com> wrote in message
news:1118127111.764497.243530@g47g2000cwa.googlegroups.com...
> 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
>
| |
| Marcelo 2005-06-08, 8:59 am |
| Thank you very much! And the FAQ site is really very good. Now in my
favourites :o)
Marcelo Schio
|
|
|
|
|