DoEvents( HWND hWnd )
{
MSG msg;
long sts;
do
{
if (sts = PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} while (sts);
}
Win32 - Force message queue evaluation
I have a program which does some heavy computing that takes up quite a bit of time. The result is that the graphical window freezes up while all this computing is going on and it becomes a bit annoying waiting for the computation to stop so that I get this little break and the graphic screen updates.
Is there a way to force the window to update and respond to any events in its message queue in the middle of my compute operation? There is a particular loop in which an update at each iteration or after x many iterations an update might be useful. I thought about
InvalidateRect(m_hwndConsole, NULL, TRUE);
UpdateWindow(m_hwndConsole);
But that will just force a redraw, correct? Can I force the window to process its message queue completely and then come back to the computations for another round?
-Kirk
EDIT: This would somethink akin to DoEvents() in VB.
EDIT2: Nevermind - I found this. I left this message in place for future surfers.
[Edited by - kirkd on February 7, 2008 6:38:22 PM]
You should be able to make a duplicate message pump at the desired location (I've seen this done in DOS-to-Windows ports). Just make sure that your message handler doesn't become infinitely recursive.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement