I have a situation where I want SendMessagea window that was created in a different thread than the one that calls SendMessage.
SendMessage
The default behavior looks forever and does not work.
So, I changed the call PostMessagethat did not block the send stream, but the message never appears on the intended window.
PostMessage
So, how am I SendMessagein a window created in a separate thread, or is this impossible?
, , , WndProc , . SendMessage PostMessage .
PostThreadMessage . , . ?
, ? , , . GetMessage/TranslateMessage/DispatchMessage. - - , , -, - , , : SendMessage , PostMessage , .
, , , MsgWaitForMultipleObjects .
. , SendMessage , windowProc SendMessage , .
PostMessage ( , -), , .
SendMessageTimeout.
SendMessageTimeout
CWnd:: PostMessage CWnd:: SendMessage . . SendMessage ; , , .
MSDN SendMessage:
"The SendMessage function calls the window procedure for the specified window and does not return until the window procedure processes the message."
You can send a message to a window in another thread using CWnd :: PostThreadMessage or winapi PostMessage . When you create a window, you can use GetSafeHwnd () to get the handle, or you can use the stream identifier when creating the stream.