【发布时间】:2021-08-07 22:53:50
【问题描述】:
我在 Win 10 上的 Visual Studio 2019 中编写了一个简单的Win32 App。在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);
}
...
}
我得到以下输出:
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
...
奇怪的是,像 799 或 49300 这样返回到输出的消息 ID 在 WinUser.h 中不存在!所以我的问题是这些消息是什么以及它来自哪里?
【问题讨论】:
标签: c++ visual-studio winapi