A thread that calls SendMessage to send a message to another thread cannot continue executing until the window procedure that receives the message returns. If the receiving thread yields control while processing the message, the sending thread cannot continue executing because it is waiting for SendMessage to return. The receiving thread need not yield explicitly. Calling any of the following functions can cause a thread to yield control:
DialogBox
DialogBoxIndirect
DialogBoxIndirectParam
DialogBoxParam
GetMessage
MessageBox
PeekMessage
A window procedure can determine whether a message it receives was sent by another thread by calling the InSendMessage function. Before calling any of the functions in the preceding list while processing a message, the window procedure should first call InSendMessage. If InSendMessage returns TRUE, the window procedure must call the ReplyMessage function before calling any function that yields control.
As an alternative, an application can use a system-modal dialog box or message box. Because system-modal windows prevent other windows from receiving messages or the keyboard focus, an application should use system-modal windows only when necessary.