全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1871
推到 Plurk!
推到 Facebook!

About PostMessage and SendMessage

尚未結案
marker
一般會員


發表:9
回覆:5
積分:2
註冊:2004-11-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-22 19:08:23 IP:210.177.xxx.xxx 未訂閱
Hi all, I just want to know the difference between PostMessage and SendMessage. Thanks for any reply. Mark Leung
jow
尊榮會員


發表:66
回覆:751
積分:1253
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-12-22 19:46:21 IP:220.130.xxx.xxx 未訂閱
The difference between SendMessage() and PostMessage() is that, as we call PostMessage() it has not to wait for response what the destination returned, while call SendMessage() has to.
marker
一般會員


發表:9
回覆:5
積分:2
註冊:2004-11-05

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-12-31 14:50:33 IP:210.177.xxx.xxx 未訂閱
jow, I still feel not sure for this. Can you make some simple example to show their differences? Mark Leung
deity
尊榮會員


發表:90
回覆:876
積分:678
註冊:2003-05-09

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-12-31 15:18:12 IP:218.15.xxx.xxx 未訂閱
marker您好: PostMessage 和SendMessage的区别主要在于是否等待其他程序消息处理。PostMessage只是把消息放入队列,不管其他程序是否处理都返回,然后继续执行;而SendMessage必须等待其他程序处理消息后才返回,继续执行。这两个函数的返回值也不同,PostMessage的返回值表示PostMessage函数执行是否正确,而SendMessage的返回值表示其他程序处理消息后的返回值。 example:
var
  Form1: TForm1;
  UserMessage1,UserMessage2:UINT;
implementation    {$R *.dfm}    procedure TForm1.FormCreate(Sender: TObject);
begin  
 {register the user defined message}
  UserMessage1 := RegisterWindowMessage('System Wide User Defined Message');
  UserMessage2 := RegisterWindowMessage('PostMessage Test Message');  
end;    //try sendMessage
procedure TForm1.Button1Click(Sender: TObject);
var
  ReturnValue: LRESULT;   // holds the result returned by SendMessage
begin
  {send the user defined message to the specified window}      ReturnValue := SendMessage(FindWindow('TForm1','RegisterMessage Get Example'),
                             UserMessage, 0, 0);      {display the result of the message processing}
  Button1.Caption := 'SendMessage Result: ' IntToStr(ReturnValue);
end;    //try postmessage
procedure TForm1.Button2Click(Sender: TObject);
begin
  {post the user defined message to the specified window's
   message queue}
  PostMessage(FindWindow('TForm1','PostMessage Get Example'), UserMessage2, 0,0);      {this message box will pop up immediately, as PostMessage
   does not wait for the message to be processed.}
  ShowMessage('Returned');
end;
try try see~~ ============================= 为什么经过多年以后,得失的过程如此冷漠 ============================= 發表人 - deity 於 2004/12/31 15:56:26
系統時間:2024-05-14 17:31:18
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!