Sign in to follow this  

Win32 - Force message queue evaluation

This topic is 3598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
DoEvents( HWND hWnd )
{
    MSG msg;
    long sts;

    do
    {
        if (sts = PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    } while (sts);
}

[Edited by - kirkd on February 7, 2008 6:38:22 PM]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this