现在的位置: 首页 > 综合 > 正文

PostMessage和SendMessage的区别

2013年10月14日 ⁄ 综合 ⁄ 共 955字 ⁄ 字号 评论关闭

1.PostMessage  
  The   PostMessage   function   places   (posts)
  a   message   in   the   message   queue   associated   with   the  
thread   that   created   the   specified   window   and   returns  
without   waiting   for   the   thread   to   process   the   message.
   
   
2.SendMessage  
  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.    
  To   send   a
  message   and   return   immediately,   use   the  
SendMessageCallback   or   SendNotifyMessage   function.   To   post  
a   message   to   a   thread's   message   queue   and   return  
immediately,   use   the   PostMessage   or   PostThreadMessage  
function. 

 

PostMessage消息发出后不等消息函数处理完就执行它的下一语句  
SendMessage消息发出后阻塞等消息函数处理完执行它的下一语句

 

例如:

一个按钮向发一个消息,然后弹出一个模态对话框。

当你高速点击该按钮时,采用postmessage可能会产生多次点击事件,导致弹出多个模态对话框

而使用sendmessage,一次点击后必须响应后才能出来下一次点击,就可以避免以上问题 

 

闻香止步 淘宝店 摆件 饰品 *木雕系列*:海南黄花梨、越南黄花梨、草花梨、小叶紫檀、黑檀、绿檀木、黄杨木、桃木发簪  木梳 樟木壁挂 佛珠 车饰 摆件
收藏送礼佳品
http://shop36570193.taobao.com

抱歉!评论已关闭.