About PostMessage and SendMessage |
尚未結案
|
marker
一般會員 發表:9 回覆:5 積分:2 註冊:2004-11-05 發送簡訊給我 |
|
jow
尊榮會員 發表:66 回覆:751 積分:1253 註冊:2002-03-13 發送簡訊給我 |
|
marker
一般會員 發表:9 回覆:5 積分:2 註冊:2004-11-05 發送簡訊給我 |
|
deity
尊榮會員 發表:90 回覆:876 積分:678 註冊:2003-05-09 發送簡訊給我 |
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 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |