1. postmessage only puts the message into the queue. No matter whether other programs process the message or not, the message is returned and then executed. This is an asynchronous message serving function. The sendmessage function is a synchronous message serving function. It must be returned after other programs process the message. In addition, the return value of postmessage indicates whether the postmessage function is correctly executed, and the return value of sendmessage indicates the return value after other programs process messages. Everyone should understand this.
2. If a message is sent by a postmessage in the same thread, the message must be placed in the thread's message queue and then sent to the target window through message loop dispatch. When sendmessage sends a message, the system directly calls the message processing program in the target window and returns the result. Sendmessage sends messages in the same thread but not in the thread message queue.
If it is in different threads. It is best to use postthreadmessage instead of postmessage, which works well. Sendmessage sends a message to the Message Queue of the thread to which the target window belongs, and then the thread that sends the message waits (in fact, he should be doing some monitoring work, such as monitoring the qs_sendmessage flag ), the message sending thread continues to run until the target window is processed and the result is returned. This is the general situation of sendmessage. In fact, the processing process is much more complicated. For example, when the sending thread detects that a message is sent to another window, it directly calls the window processing process (re-import ), and return the processing result (this process does not require the support of getmessage in the message loop ).
3, msdn: If you send a message in the range below wm_user to the asynchronous message functions (postmessage, sendpolicymessage, and sendmessagecallback), its message
Parameters can not include pointers. otherwise, the Operation will fail. if the sent message code is under wm_user (non-custom message) and the message parameters contain pointers, the asynchronous message sending functions postmessage, sendpolicymessage, and sendmessagecallback will fail to be called. It is best not to use postmessage to send messages with pointer parameters.