windows消息机制

 系统会为每一个线程自动创建一个消息队列。如果线程创建一个或多个窗口,那必须提供一个消息循环,这个消息循环会从线程消息队列获得消息,并把他们派发到相应的窗口过程。

因为系统会直接把消息送到程序中的每个窗口,一个线程要在启动他的消息循环之前至少创建一个窗口。

The system queue never contains window messages; its sole duty is to record hardware events as they happen at interrupt time.The only way to get an event into the system queue is to call the special event entry points in USER.EXE.
系统队列绝不会包含windows消息,它的唯一的责任是记录周期性产生的硬件事件。获取系统队列里事件唯一的方法是调用USER.EXE里专门的函数。

This application queue (sometimes referred to as a task queue) is used to store messages that have been posted to one of the application's windows. The only messages that ever reside in an application's queue are those that are explicitly posted using PostMessage or PostAppMessage. (SendMessage never uses the system queue.) The PostQuitMessage function does not post a message to an application queue. (The WM_QUIT message will be discussed later.)
应用程序队列被用来保存发送给这个应用程序窗口的消息。只有通过PostMessage或PostAppMessage函数发送的消息才会进入应用程序消息队列。
SendMessage从来不使用系统队列。PostQuitMessage不会把消息发送到应用程序队列。

GetMessage和PeekMessage在windows内部执行相同的代码,它们之间主要的不同在于,当应用程序队列中没有消息时候,在这种情况下GetMessage会让程序sleep,而PeekMessage返回NULL。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值