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.
HWND hWnd ,
UINT Msg ,
WPARAM wParam ,
LPARAM lParam
);
The return value specifies the result of the message processing; it depends on the message sent.
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.
To post a message in the message queue associate with a thread, use the PostThreadMessage function.
HWND hWnd ,
UINT Msg ,
WPARAM wParam ,
LPARAM lParam
);
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
在MSDN上的定义如上,顾名思义,send有“发送”而post有“邮寄“的意思。我们可以这样子理解,send就是直接传递消息,而post是送到某个中介,然后让中介完成传递消息。既然send是直接发送的,那么它就不进入队列。而post就需要在中介那里排队等待发送。至于处理过程,send要发送到目的地(窗口等),等待目的地处理完才回家;而post送到中介后就回去了。
返回值,send的返回值代表目的地处理消息的返回结果;post的返回值仅代表此PostMessage是否执行成功。
相关资料:http://www.cnblogs.com/McJeremy/archive/2009/09/28/1575741.html
http://www.itcodeworld.com/?p=75