How to send SendMessage () to a window created in another thread?

I have a situation where I want SendMessagea window that was created in a different thread than the one that calls 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.

So, how am I SendMessagein a window created in a separate thread, or is this impossible?

+4
source share
5 answers

, , , WndProc , . SendMessage PostMessage .

+1

PostThreadMessage . , . ?

+1

, ? , , . GetMessage/TranslateMessage/DispatchMessage. - - , , -, - , , : SendMessage , PostMessage , .

, , , MsgWaitForMultipleObjects .

+1

. , SendMessage , windowProc SendMessage , .

PostMessage ( , -), , .

SendMessageTimeout.

+1

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.

0
source