原文:
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將指定的消息發(fā)送到一個(gè)窗口或多個(gè)窗口。SendMessage為這個(gè)指定的消息調(diào)用窗口處理程序,直到窗口處理完這個(gè)程序后才會返回。和SendMessage函數(shù)相比,PostMessage函數(shù)發(fā)送一個(gè)消息到線程消息對列中,并立即返回。
辨析:
shuishi32
在給出翻譯的還給對ddlddy的問題:“我用SendMessage(hWnd,WM_QUIT,NULL,NULL)和PostMessage(hWnd,WM_QUIT,NULL,NULL)去關(guān)閉一指定窗口,SendMessage的不能實(shí)現(xiàn),可以解釋一下嗎?我主要的就是想知道這個(gè)!”給出了解答:WM_QUIT是通知系統(tǒng)關(guān)閉,這個(gè)消息只有系統(tǒng)通過GetMessage來返回0達(dá)到線程關(guān)閉的。而SendMessage發(fā)送的消息不會到系統(tǒng)對列中,它只是處理,而PostMessage就會發(fā)送到系統(tǒng)隊(duì)列中。
另外可以用SendMessage(hWnd, WM_CLOSE, 0, 0);來關(guān)閉對話框。