windows - PostMessage() 消息在 Windows 中是否按顺序显示?

标签 windows mfc postmessage

一般的问题是,如果我从一个单独的工作线程向 Windows 消息泵发送多条消息,它们会按照我发送的顺序出现在目的地吗?即..

::PostMessage(m_hUsers, WM_BULKPROCESS, 0, 0);
// ... some processing here ...
::PostMessage(m_hUsers, WM_BULKDONE, 0, 0);

m_hUsers 是我从我的工作线程向其发送消息的窗口的句柄 (HWND)。那么,WM_BULKPROCESS 是否总是首先出现在窗口中(因此由该对话框类中的处理程序处理),或者它们是否有可能乱序,即 WM_BULKDONE 在 WM_BULKPROCESS 之前得到处理,即使它是最后发送的?

最佳答案

有一些异常(exception)(如 WM_PAINT),但一般来说,消息的顺序是保持不变的。 如果消息以错误的顺序出现,试图理解鼠标输入的图像!

引用自 GetMessage

During this call, the system delivers pending, nonqueued messages, that is, messages sent to windows owned by the calling thread using the SendMessage, SendMessageCallback, SendMessageTimeout, or SendNotifyMessage function. Then the first queued message that matches the specified filter is retrieved. The system may also process internal events. If no filter is specified, messages are processed in the following order:

Sent messages
Posted messages
Input (hardware) messages and system internal events
Sent messages (again)
WM_PAINT messages
WM_TIMER messages

关于windows - PostMessage() 消息在 Windows 中是否按顺序显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7435696/

相关文章:

windows - Linux/Unix中 "Performance Counters"的概念

python - 为什么我收到 ModuleNotFoundError,当它安装在 sys.path 上时?

python - 在Windows Anaconda2上安装Tensorflow

c++ - 如何在 Windows 8.1/10 上可靠地窃取/重新获得 MFC/桌面应用程序的焦点?

c++ - 静态和动态 MFC 链接

javascript - 未处理的 postMessage 会泄漏内存吗?

windows - 使程序出现在前台但不可点击

c++ - win32 项目的错误 C2146

events - 使用点击事件从 iframe 向父级发送消息

c++ - PeekMessage 没有收到消息?