> > Writing to opened (.txt file) notepad is solved.
> > PROBLEM : when vc++ application, is writing data to opened notepad, then
[quoted text clipped - 13 lines]
> Regards,
> Will
Hi!
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.
code: working for only when one notepad is opend / for top notepad at desktop
HWND hNotepad, hEdit;
hNotepad = ::FindWindow("Notepad",NULL);
hEdit = ::FindWindowEx(hNotepad, NULL,"edit", NULL);
int iLength = (int)::SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0);
::SendMessage(hEdit, WM_GETTEXT, iLength+1, (LPARAM)textData);
CString temp = textData;
temp += "\r\n";
temp += "MFC";
::SendMessage(hEdit, WM_SETTEXT,0,(LPARAM)textData);
I had try..... ( Not working.. if more then one / abc.txt is not at top in
desktop)
hNotepad = ::FindWindow("Notepad","abc.txt");
hNotepad = ::FindWindow("Notepad","abc");
HWND FindWindow( LPCTSTR lpClassName, LPCTSTR lpWindowName); //syntax
If the lpWindowName parameter is not NULL, FindWindow calls the
GetWindowText function to retrieve the window name for comparison.
GetWindowText cannot retrieve the text of a control in another application.
How to select specfic txt file... if more then one is opened!
I want to write the data in specfic file that i supply in program
Help Me Please
> Dear William
>
[quoted text clipped - 21 lines]
> > Regards,
> > Will
William DePalo [MVP VC++] - 07 Feb 2005 15:17 GMT
> 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.
OK.
To answer the question you asked, what you need to do is to change this
line:
hNotepad = ::FindWindow("Notepad",NULL);
to
hNotepad = ::FindWindow("Notepad","abc.txt - Notepad");
Notepad is little more than a frame window with an edit control child and a
menu. You might want to think about using your own frame and edit control so
that you could maintain an association between window handles and file names
and note have to use FindWindow().
Regards,
Will
Sandy - 19 Feb 2005 07:17 GMT
Hi
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?
> > If more than one notepad is opened in desktop.. then its work for "top"
> > notepad only
[quoted text clipped - 21 lines]
> Regards,
> Will
William DePalo [MVP VC++] - 20 Feb 2005 01:09 GMT
> In the same discussion... Can i get current cursor position in open
> notepad
[quoted text clipped - 4 lines]
> i
> get it?
Notepad contians an edit control. Edit controls provide messages both to
report on and change the current selection.
Check the docs for EM_GETSEL. It gets the "selection range". The end of the
range is where the caret (what you call cursor) is. You can use
EM_LINEFROMCHAR and the end of the selection range to get the line number
containing the caret. EM_LINEINDEX can be used to get the first character of
a given line. Subtracting the two positions will yield the offset from the
start of the line.
You should either post follow-up in a UI group or check the docs for the
messages that edit controls support. The messages that are specific to edit
controls have names that begin with "EM_"
Regards,
Will