ROOKIE
April 5th, 1999, 10:19 AM
I am attempting to use SendMessage to control an application from within my own app. I am attempting to use the menu commands by issuing WM_CHAR and WM_SYSCHAR messages. I am using notepad to practice trying to close an app via the menu. Anyone with any suggestions, please respond.
(if you use the code below, make sure that you have a new instance of Notepad running or you will get an error.)
{
CWnd* hwnd;
hwnd = FindWindow(NULL, "Untitled - Notepad");
char* d;
char buf[80];
sprintf(buf, "fx");
d = '\0';
if(buf[0]!='\0'){
d = buf;
while(*d){
hwnd->SendMessage( WM_SYSCHAR,*d,1L);
d++;
hwnd->SendMessage( WM_CHAR,*d,1L);
d++;
}
}
}
(if you use the code below, make sure that you have a new instance of Notepad running or you will get an error.)
{
CWnd* hwnd;
hwnd = FindWindow(NULL, "Untitled - Notepad");
char* d;
char buf[80];
sprintf(buf, "fx");
d = '\0';
if(buf[0]!='\0'){
d = buf;
while(*d){
hwnd->SendMessage( WM_SYSCHAR,*d,1L);
d++;
hwnd->SendMessage( WM_CHAR,*d,1L);
d++;
}
}
}