For Programmers: Free Programming Magazines  


Home > Archive > VC Language > 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, 9:02 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.

Micus

2005-06-07, 9:00 pm


"Marcelo" <marschio@msn.com> wrote in message
news:1118126967.011043.11660@o13g2000cwo.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.
>


You need to place the drawing in the WM_PAINT handler for it to redraw when
you min/max the window.
HTH - M


Marcelo

2005-06-08, 9:00 am

Thank you very much. I really need to use the piant event.

Marcelo Schio

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com