Re: repainting a dialog
Hi Dave,
The other Dave's idea about a thread is pretty good. What you're seeing is
probably the result of the window just not getting messages for a while
since your loop is hogging cycles.
However, to answer your question, you can call RedrawWindow() or
Invalidate() and then UpdateWindow() for any window you want to redraw. It
may not happen right away though so you'll want to free up some time. You
could call a function like the one below every so often during your loop
(certainly not needed every time through the loop) to cause messages to get
processed and reduce the effect of blocking
Tom:
//
// Release main thread for background processing
//
void GiveTime()
{
// Idle until the screen redraws itself, et. al.
MSG msg;
while (::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) {
if (!AfxGetThread()->PumpMessage( )) {
::PostQuitMessage(0);
break;
}
}
// let MFC do its idle processing
LONG lIdle = 0;
while (AfxGetApp()->OnIdle(lIdle++ ))
;
}
"Dave Cullen" <nospam@mail.com> wrote in message
news:4609869F.8F2D3B82@mail.com...
I have a dialog based application that spends most of its time in loops
controlling a machine. The only window activity is regular updates of
text in static text boxes. If the dialog displays a MessageBox to the
operator, the screen underneath will not be visible when the box closes.
Is there a method of forcing the window to completely redraw itself that
I can call periodically, especially after displaying a messagebox?
Thanks