How come I can WM_CLOSE an out-of-process Notepad but can't get it to display a WM_CHAR?
-
In my simple win32 pgm I launch Notepad, CreateProcess("c:\\winnt\\notepad.exe"... then get a handle to it, hwndTarget = FindWindow(NULL, TEXT("Untitled - Notepad")); then close it with no problem, SendMessage(hwndTarget, WM_CLOSE, 0, 0); But if instead of closing it I try to Post/Send it a character to display PostMessage (hwndTarget, WM_CHAR, 'x', 1) ; SendMessage (hwndTarget, WM_CHAR, 'z', 1) ; it doesn't work. So I'm missing something here, but don't know what it is. Thanks for any assistance! glyfyx
-
In my simple win32 pgm I launch Notepad, CreateProcess("c:\\winnt\\notepad.exe"... then get a handle to it, hwndTarget = FindWindow(NULL, TEXT("Untitled - Notepad")); then close it with no problem, SendMessage(hwndTarget, WM_CLOSE, 0, 0); But if instead of closing it I try to Post/Send it a character to display PostMessage (hwndTarget, WM_CHAR, 'x', 1) ; SendMessage (hwndTarget, WM_CHAR, 'z', 1) ; it doesn't work. So I'm missing something here, but don't know what it is. Thanks for any assistance! glyfyx
The problem is that you're sending the messages to the main window. Maybe the edit control that processes the chars is a child window of the main. You can find it with spy++. Hope it helps
rotter The metaller programmer
-
In my simple win32 pgm I launch Notepad, CreateProcess("c:\\winnt\\notepad.exe"... then get a handle to it, hwndTarget = FindWindow(NULL, TEXT("Untitled - Notepad")); then close it with no problem, SendMessage(hwndTarget, WM_CLOSE, 0, 0); But if instead of closing it I try to Post/Send it a character to display PostMessage (hwndTarget, WM_CHAR, 'x', 1) ; SendMessage (hwndTarget, WM_CHAR, 'z', 1) ; it doesn't work. So I'm missing something here, but don't know what it is. Thanks for any assistance! glyfyx
Thanks rotter - I believe that's it! I used Spy++ (for the first time!) and found what looks very much like a child window and its handle under Notepad. Now what I have to do is figure out how to obtain the child's handle in my code then send WH_CHAR to it. Big help - thanks! glyfyx