I have 2 apps,one is hidden window ("hW"), another is console app ("CA"),from which i suppose to send commands to hW. In console app i'm getting hW handle,and here is a question: if i'm running:
PostMessage(hwnd, WM_QUIT, NULL, NULL);
everything works fine, message gets to hW and turns it off .But if i'm sending
PostMessage(hwnd, WM_SETTEXT, NULL, (LPARAM)"texttext");
message does not get to hW at all. Spy++ also shows that message does not get to hW. Is there something specific about WM_SETTEXT , which prevents it? Thanks in advance.
OK. found 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....
P.P.S.
Also, looks like
SendMessage(hwnd, WM_QUIT, NULL, NULL);
does not do anything to target app.Even in simple test app like
HWND hNote;
if (!(hNote=FindWindow(L"Notepad",NULL)))
exit(1);
SendMessage(hNote, WM_QUIT, NULL, NULL);
while
PostMessage(hNote, WM_QUIT, NULL, NULL);
works.
All that looks so not logical for me... Is there some universal function which works properly with any kind of message?