首页 > 解决方案 > Message id's in the main application loop

问题描述

I've written a simple Win32 App in Visual Studio 2019 on Win 10. In the main message loop inside the WinMain function i have:

while (Msg.message != WM_QUIT) {

    if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE) > 0) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);

        swprintf_s(msgbuf, _T("In the PeekMessage loop cnt: %d, msg: %d\n"), loop_cnt++, Msg.message);
        OutputDebugString(msgbuf);
    }
...
}

I get following output:

In the PeekMessage loop cnt: 0, msg: 799
In the PeekMessage loop cnt: 1, msg: 49300
In the PeekMessage loop cnt: 2, msg: 96
In the PeekMessage loop cnt: 3, msg: 96
In the PeekMessage loop cnt: 4, msg: 275
In the PeekMessage loop cnt: 5, msg: 275
...

The odd is that the messages id's returned to the output like 799 or 49300 doesn't exist in the WinUser.h! So my question is what that messages are and where it comes from?

标签: c++visual-studiowinapi

解决方案


799 is WM_DWMNCRENDERINGCHANGED.

49300 is a registered message (i.e. its value is in the range 0xC000-0xFFFF).


推荐阅读