jeurk
asked on
[D3 winAPI] Get the text from another's app memo
Hello,
I'd like to read the contain of the memo
that is in another app.
Using windows messages.
I already have the handle of that
memo.
Let's say I have a memo. Help me read
another memo and fill mine with it's
text.
I tryed
var
p:TPoint;
WinHandle: THandle;
Buffer: array[0..50] of Char;
begin
ReleaseCapture;
GetCursorPos(p);
WinHandle:=WindowFromPoint (p);
GetClassName(WinHandle, Buffer, SizeOf(Buffer) - 1);
edit1.Text:=Buffer;
GetWindowText(WinHandle, Buffer, SizeOf(Buffer) - 1);
edit2.Text:=Buffer;
but getwindowtext cannot get the text of another app.
Thanks to submit working code please. Thanks.
I'd like to read the contain of the memo
that is in another app.
Using windows messages.
I already have the handle of that
memo.
Let's say I have a memo. Help me read
another memo and fill mine with it's
text.
I tryed
var
p:TPoint;
WinHandle: THandle;
Buffer: array[0..50] of Char;
begin
ReleaseCapture;
GetCursorPos(p);
WinHandle:=WindowFromPoint
GetClassName(WinHandle, Buffer, SizeOf(Buffer) - 1);
edit1.Text:=Buffer;
GetWindowText(WinHandle, Buffer, SizeOf(Buffer) - 1);
edit2.Text:=Buffer;
but getwindowtext cannot get the text of another app.
Thanks to submit working code please. Thanks.
ASKER
this is working perfectly.
but I do not understand what the
line SetLength(s1, SendMessage(WinHandle, WM_GETTEXT, i1 + 1, integer(s1)));
does and how it is working.
does not setlenght change the size of the given string ?
but I do not understand what the
line SetLength(s1, SendMessage(WinHandle, WM_GETTEXT, i1 + 1, integer(s1)));
does and how it is working.
does not setlenght change the size of the given string ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello,
thanks for your help.
and for the crystal clear comments.
About memo1.text := Window(WinHandle).Text;
are your doing more then GetWindowText(WinHandle, Buffer, SizeOf(Buffer) - 1);
?
I hope so. Anyway I'm gonna like your stuff life always.
CU
thanks for your help.
and for the crystal clear comments.
About memo1.text := Window(WinHandle).Text;
are your doing more then GetWindowText(WinHandle, Buffer, SizeOf(Buffer) - 1);
?
I hope so. Anyway I'm gonna like your stuff life always.
CU
I don't use GetWindowText, because it doesn't work alright. In my stuff I'm doing exactly what I've posted here (in fact the code I've posted here is just a slightly changed copy from my stuff)... :-)
ASKER
Anyway I believe you.
Look I have another question
(just give me five minutes to type it;)
Look I have another question
(just give me five minutes to type it;)
This should work:
var i1 : integer;
s1 : string;
begin
i1 := SendMessage(WinHandle, WM_GETTEXTLENGTH, 0, 0);
SetLength(s1, i1 + 1);
SetLength(s1, SendMessage(WinHandle, WM_GETTEXT, i1 + 1, integer(s1)));
memo1.text := s1;
Regards, Madshi.