Tech Support > Microsoft Windows > Development Resources > Repainting device context
Repainting device context
Posted by Tristan on August 22nd, 2003


I've got an application which calls some code to draw
to the graphics context of the current form when a
button is pressed:

CDCDrawDlg::OnOK()
{
CClientDC canvas(this);

DoDrawing(canvas);
}

I don't want what is drawn to disappear but if I
call my drawing code from the OnPaint() event handler then
the drawing will happen whether or not the button has been
pressed (i.e. straight away).

How can I ensure what has been drawn to the graphics
context remains persistent on the form in such a case.

Many thanks

Tristan.

Posted by Tim Robinson on August 22nd, 2003


In OnOK, set a member variable to true. In OnPaint, check if that variable
has been set.

--
Tim Robinson (MVP, Windows SDK)
http://www.themobius.co.uk/

"Tristan" <tristan_sehgal@yahoo.co.uk> wrote in message
news:7f5eb42c.0308220053.5c46a38c@posting.google.c om...