G
Guest
can mfc application, send text data to opened notepad file in desktop?(live
transfer of data) . can anybody help
transfer of data) . can anybody help
Sandy said:can mfc application, send text data to opened notepad
file in desktop?(live transfer of data) . can anybody help
William DePalo said:Sandy said: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
Sandy said:Dear William
1. Suppose "abc.txt"(notepad) file is already open in desktop.
2. My VC++6 mfc, application wants to write the data in abc.txt.
example...when u open abc.txt then... in notepad there are 5line of text
,
then new data should be display in 6th line... that 6th line coming in
notepad is seen by user. that 6th line data is coming from your vc++
appln.
Thanks
William DePalo said:Sandy said: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
to be most general, why don't you simply offer to copy the text to theSandy said:can mfc application, send text data to opened notepad file in desktop?(live
transfer of data) . can anybody help
Sandy said:Writing to opened (.txt file) notepad is solved.
PROBLEM : when vc++ application, is writing data to opened notepad, then
small
------------ rectangle are coming in .txt file
"\n" is also not working.
Sandy said:If more than one notepad is opened in desktop.. then its work for "top"
notepad only
Want to ... write a data in specfic .txt file. for example abc.txt, but if
"top.txt" is at top at desktop then, the data is written in top.txt....
not
in abc.txt.
Sandy said:In the same discussion... Can i get current cursor position in open
notepad
hNotepad = ::FindWindow("Notepad","abc.txt - Notepad");
Bcoz i want insert data at current cursor position..
Example; if notepad file having 10 line and my cursor is at 5 line... can
i
get it?