PostMessage和SendMessage的區別

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章