开发者

Win32: What is making my message loop work incorrectly in that example?

开发者 https://www.devze.com 2023-01-31 04:36 出处:网络
I recently ran into a situation where I wanted to use a modeless dialog in Win32\'s. Win32: Toolbar dialog seems to never get focus and causes the main window to process slow!?

I recently ran into a situation where I wanted to use a modeless dialog in Win32's.

Win32: Toolbar dialog seems to never get focus and causes the main window to process slow!?

And I figured out that this was my message loop:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
    // Doing required stuff here...

    while (GetMessage(&Msg, hWnd, 0, 0) > 0) {
        // Processing messages here...
    }
}

In fact, this message loop works fine as long as I don't have any modeless dialog, as it works perfectly fine with modal dialogs, since they process their own message loop. My modeless dialog worked flawlessly when I replaced the hWnd instance for NULL. I just don't get the difference, except that it seems that I get the messages not for one particularly window.

Can so开发者_StackOverflowmeone explain what is making this message loop work inccorectly?

As this one:

while (GetMessage(&Msg, NULL, 0, 0) > 0) {
    // Processing messages here...
}

works flawlessly!


the difference is pretty obvious: you specified a HWND in GetMessage. So, you are not processing any messages for any other windows, your toolbar included. See the docs for GetMessage

0

精彩评论

暂无评论...
验证码 换一张
取 消