What is the difference between PostMessage and SendMessage?

xiaoxiao2021-03-06  53

When controlling other applications, you often need to wait until a feature end, for example: open a window-> Waiting until the window can be used to use SendMessage if you still need the window of the window after opening this window Setting, such as Value, such as EDIT, such as: Open a window -> Control window of the Control at this time you need postMessage

After using a hook program to intercept the message, use sendMessage to send the message to the primary handler, but when the main handler has not completed the task, the program set the hook will enter the stopped state, and can not process WM_Paint, WM_MOVE, ....... The basic information must wait until the message sent by SendMessage can continue to run, the entire interface is blank, and the hook message is set to the message form of PostMessage, the problem is solved! I checked it. MSDN's definition of these two APIs, postmessage just puts the message into the queue, whether it is returned if other programs are handled, then continue; while SendMessage must return to other programs to return, continue. PostMessage's return value indicates whether the PostMessage function is executed correctly; and the return value of SendMessage indicates the return value after another program processes the message. The most important thing to use these two sending message functions is to see if your program is to be hysteresis, postmessage will cause the hysteresis of the message, while SendMessage will not, but if the sendMessage message failed, Cause the program stop!

转载请注明原文地址:https://www.9cbs.com/read-117537.html

New Post(0)