while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))

项目中用到了好多这个消息循环,很是困惑。遂百度之,难道一个窗口下可以有多个消息循环吗?百度结果都是介绍和GetMessage区别的,正经的说这个有啥作用的,少之又少。不过有一篇英文的不错,这是出处,可以参考一下

http://blog.csdn.net/scofieldlau/article/details/1965517#t0

。奈何我的疑惑仍然为解。最后查看MSDN,清晰一二

原文

Unlike the GetMessage function, the PeekMessage function does not wait for a message to be placed in the queue before returning.

PeekMessage retrieves only messages associated with the window identified by thehWnd parameter or any of its children as specified by theIsChild function, and within the range of message values given by thewMsgFilterMin andwMsgFilterMax parameters. If hWnd is NULL,PeekMessage retrieves messages for any window that belongs to the current thread making the call. (PeekMessage does not retrieve messages for windows that belong to other threads.) IfhWnd is –1, PeekMessage only returns messages with ahWnd value of NULL, as posted by thePostThreadMessage function. IfwMsgFilterMin andwMsgFilterMax are both zero,PeekMessage returns all available messages (that is, no range filtering is performed).

The WM_KEYFIRST and WM_KEYLAST constants can be used as filter values to retrieve all keyboard messages; the WM_MOUSEFIRST and WM_MOUSELAST constants can be used to retrieve all mouse messages.

The PeekMessage function does not remove WM_PAINT messages from the queue. WM_PAINT messages remain in the queue until they are processed.


翻译

PeekMesssge只得到那些与参数hWnd标识的窗口相联系的消息或被lsChild确定为其子窗口相联系的消息,并且该消息要在由参数wMsgFiterMin和wMsgFiherMax确定的范围内。如果hWnd为NULL,则PeekMessage接收属于当前调用线程的窗口的消息(PeekMessage不接收属于其他线程的窗口的消息)。如果hWnd为-1,PeekMessage只返回hWnd值为NULL的消息,该消息由函数PostThreadMessage寄送。如果wMsgFilterMin和wMsgFilterMax都为零,PeekMessage返回所有可得的消息(即,无范围过滤)。

常数WM_KEYFIRST和WM_KEYLAST可作为过滤值取得所有键盘消息;常数WM_MOUSEFIRST和WM_MOUSELAST可用来接收所有的鼠标消息。
PeekMessage通常不从队列里清除WM_PAINT消息。该消息将保留在
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值