注册 登录
编程论坛 VC.NET论坛

[求助] SendMessage发送的消息是否会被GetMessage处理?

hixiaopeng 发布于 2006-04-14 14:12, 2354 次点击

MSDN中有两段关于GetMessage与SendMessage的话:

1.---The SendMessage function is used to send a message directly to a window procedure.
The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.

2.---The GetMessage function retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval.

疑问:
即然第一句说Sendmessage函数将消息直接发送给Winpro函数处理的, 也就是不用经过线程消息队列喽, 但是上面第二这句话为什么又说当在线程消息队列中没有可用的Posted消息时, GetMessage函数会将Sent来的消息dispatch呢,这应该不属于GetMessage的责任啊? Sendmessage发来的消息应该与Getmessage函数没关系吧, 请问是我是否理解错误?

还有一个问题: 消息队列有系统消息队列和线程消息队列两种,我想问是不是所有的消息都要先进入系统消息队列, 然后再由系统将其post到相应线程队列或者直接send给winpro处理呢?谢谢

[此贴子已经被作者于2006-4-14 14:28:30编辑过]

2 回复
#2
sdpdww2006-05-11 20:17
相对于98的sendmessage的函数,nt内核的系统确实做了处理,但是还是可以通过一些手段,比如用系统钩子,但是直接使用Getmessage时截取不到的
#3
sdpdww2006-05-11 20:22

至于你后面的那个问题,那是肯定的,所有的消息包括系统自己的消息,都是要“排队”的,不过消息也有不同的优先级,系统会先处理优先级高的消息

1