主应用程序循环中的消息 ID

Dar*_*911 0 c++ winapi visual-studio

我写了一个简单Win32 App的Visual Studio的2019对10场。在WinMain函数内的主消息循环中,我有:

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);
    }
...
}
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

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
...
Run Code Online (Sandbox Code Playgroud)

奇怪的是,消息 id 返回到输出,就像799或49300不存在于 WinUser.h 中!所以我的问题是这些消息是什么以及它来自哪里?

IIn*_*ble 5

799 是WM_DWMNCRENDERINGCHANGED。

49300 是一个注册消息(即它的值在 0xC000-0xFFFF 范围内)。