Windows 消息处理 - PeekMessage
2009-02-06 10:27
190 查看
当运行复杂的计算或循环的时候,为了使windows程序不产生假死现象(不响应任何消息,cpu100%占用).要在适当地方添下如下消息处理机能。
// Process the thread's window message
MSG msg;
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
if(msg.message
== WM_QUIT) //
Check for the WM_QUIT message
break;
// Send the message to the window
procedure
TranslateMessage(&msg);
DispatchMessage(&msg);
}
另外说明:
PeekMessage和GetMessage的区别
1.GetMessage将等到有合适的消息时才返回,而PeekMessage只是撇一下消息队列.
2.GetMessage会将消息从队列中删除,而PeekMessage可以设置最后一个参数wRemoveMsg来决 定是否将消息保留在队列中.
// Process the thread's window message
MSG msg;
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
if(msg.message
== WM_QUIT) //
Check for the WM_QUIT message
break;
// Send the message to the window
procedure
TranslateMessage(&msg);
DispatchMessage(&msg);
}
另外说明:
PeekMessage和GetMessage的区别
1.GetMessage将等到有合适的消息时才返回,而PeekMessage只是撇一下消息队列.
2.GetMessage会将消息从队列中删除,而PeekMessage可以设置最后一个参数wRemoveMsg来决 定是否将消息保留在队列中.
相关文章推荐
- windows线程消息通信和处理 PostThreadMessage和PeekMessage GetMessage
- 如何捕获VCL没有处理的Windows消息
- C# 收发和处理自定义的WINDOWS消息
- Qt for windows消息循环、libqxt分析和wince快捷键处理
- java处理底层windows消息
- 2011-03-29 14:53 ActiveX控件中接收并处理Windows消息的问题
- Delphi中的消息钩子函数和Windows子类处理 入门篇
- Delphi中的消息钩子函数和Windows子类处理 入门篇
- Windows 定制控件消息处理函数
- Windows的自带控件(比如TButton)大多数消息都由它自己处理,Delphi覆盖了那么多WM_函数优先级较低,一般用不上
- C#开发WINDOWS应用程序时消息的处理
- 在WPF中处理Windows消息
- Windows窗体类消息处理
- c# Windows消息处理过程探究
- windows消息处理
- C# 收发和处理自定义的WINDOWS消息
- Windows应用程序的消息处理机制
- Windows 消息处理机制与事件驱动
- 欺骗windows---消息处理:移动窗口
- windows游戏编程 以PeekMessage为核心的消息循环体系