原文:
SendMessage sends the specified message to a window or windows. SendMessage
calls the window procedure for the specified window and does not return until
the window procedure has processed the message. The PostMessage function, in
contrast, posts a message to a thread's message queue and returns immediately.
譯文:
SendMessage將指定的消息發送到一個窗口或多個窗口。SendMessage為這個指定的消息調用窗口處理程序,直到窗口處理完這個程序后才會返回。和SendMessage函數相比,PostMessage函數發送一個消息到線程消息對列中,并立即返回。
辨析:
shuishi32
在給出翻譯的還給對ddlddy的問題:“我用SendMessage(hWnd,WM_QUIT,NULL,NULL)和PostMessage(hWnd,WM_QUIT,NULL,NULL)去關閉一指定窗口,SendMessage的不能實現,可以解釋一下嗎?我主要的就是想知道這個!”給出了解答:WM_QUIT是通知系統關閉,這個消息只有系統通過GetMessage來返回0達到線程關閉的。而SendMessage發送的消息不會到系統對列中,它只是處理,而PostMessage就會發送到系統隊列中。
另外可以用SendMessage(hWnd, WM_CLOSE, 0, 0);來關閉對話框。