"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
can mfc application, send text data to opened notepad
file in desktop?(live transfer of data) . can anybody help
I'm not sure if I understand what the crux of your question is. Is it how to
manipulate Notepad or how to do data transfer?
The former question is easy to answer. This little hack will do the job. It
is a command line application whose first parameter is the title (caption)
of the instance of Notepad to which you want to deliver the text and the
second is the text itself. If either contains spaces you'll need to quote
it.
#include <windows.h>
#include <iostream>
int main(int argc, char **argv)
{
HWND hNotepad, hEdit;
if ( argc != 3 )
{
std::cout << "Enter xxx \"title\" \"text\"" << std::endl;
std::cout << " where title is the caption of Notepad's window" <<
std::endl;
std::cout << " and text is the text you want to insert" << std::endl;
}
hNotepad = FindWindow("Notepad", argv[1]);
if ( hNotepad == 0 )
{
std::cout << "Failed to find Notepad's main window" << std::endl;
exit(0);
}
hEdit = FindWindowEx(hNotepad, NULL, "edit", NULL);
if ( hEdit == 0 )
{
std::cout << "Failed to find Notepad's edit control" << std::endl;
exit(0);
}
SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM) argv[2]);
return 0;
}
If you are asking about live data transfer in general then the answer could
(and has) filled entire books. The example above uses Windows to do the
heavy lifting - its WM_SETTEXT message is designed to move character data
into a Window. If you want to move something other than text to something
other than a window post some more details for some ideas.
Regards,
Will