I have 2 applications, one is a hidden window ("hW"), the other is a console application ("CA"), from which, I believe, sends hW commands. In a console application, I get an hW descriptor, and here's the question: if I'm running:
PostMessage(hwnd, WM_QUIT, NULL, NULL);
everything works fine, the message goes into hW and disables it. But if I send
PostMessage(hwnd, WM_SETTEXT, NULL, (LPARAM)"texttext");
the message does not get into hW at all. Spy ++ also shows that the message does not fall into hW. Is there anything special about WM_SETTEXT that prevents it? Thanks in advance.
OK found the answer here http://cboard.cprogramming.com/windows-programming/72589-wm_settext-postmessage.html
Turns out the API tries to protect me against scope issues; PostMessage ()
always fails with WM_SETTEXT, or any other system-defined message that has
a pointer as a parameter.Which gets me to SendMessage (), which is not good,
because i wanted asynchronous messaging ....
PPS
It also looks like
SendMessage(hwnd, WM_QUIT, NULL, NULL);
doesn't do anything to the target application. Even in a simple test application, for example
HWND hNote; if (!(hNote=FindWindow(L"Notepad",NULL))) exit(1); SendMessage(hNote, WM_QUIT, NULL, NULL);
while
PostMessage(hNote, WM_QUIT, NULL, NULL);
works.
Everything that looks so illogical to me ... Is there any universal function that works correctly with any kind of message?