Windows Messages Bizarreness

Posted by jameszhao00 on Stack Overflow See other posts from Stack Overflow or by jameszhao00
Published on 2010-12-22T03:12:42Z Indexed on 2010/12/22 3:54 UTC
Read the original article Hit count: 356

Filed under:
|

Probably just a gross oversight of some sort, but I'm not receiving any WM_SIZE messages in the message loop. However, I do receive them in the WndProc. I thought the windows loop gave messages out to WndProc?

LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    switch(message)
    {
        // this message is read when the window is closed
    case WM_DESTROY:
        {
            // close the application entirely
            PostQuitMessage(0);
            return 0;
        } break;
    case WM_SIZE:
        return 0;
        break;
    }
    printf("wndproc - %i\n", message);
    // Handle any messages the switch statement didn't
    return DefWindowProc (hWnd, message, wParam, lParam);
}

... and now the message loop...

while(TRUE)
{
    // Check to see if any messages are waiting in the queue
    if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {

        // translate keystroke messages into the right format
        TranslateMessage(&msg);
        // send the message to the WindowProc function
        DispatchMessage(&msg);

        // check to see if it's time to quit
        if(msg.message == WM_QUIT)
        {
            break;
        }
        if(msg.message == WM_SIZING)
        {
            printf("loop - resizing...\n");
        }
    }
    else
    {
        //do other stuff
    }
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about Windows