Solved

how to use FindWindowEx() and WM_GETTEXT

Posted on 2004-08-09
8
1,467 Views
Last Modified: 2010-04-06
2 questions:
1. I know how to use FindWindow() but how do I use FindWindowEx() ? (i need parameter description)

2. I want to get text from a TEdit (outside the form) with SendMessage() and WM_GETTEXT.  How can I do that?

din345
0
Comment
Question by:din345
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 4

Expert Comment

by:alikoank
ID: 11750769
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11750803
0
 
LVL 1

Author Comment

by:din345
ID: 11750833
thanks for your answer. i dont't know how to use SendMessage(Edit1.Handle,  WM_GETTEXT,  bBytes, szBuffer)

bBytes and szBuffer - what's that?

I want to show the grabbed text like this: ShowMessage(SendMessage(Edit1.Handle,  WM_GETTEXT,  bBytes, szBuffer));

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:din345
ID: 11750837
0
 
LVL 4

Assisted Solution

by:alikoank
alikoank earned 20 total points
ID: 11750886
try this one,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/FindWindowEx.asp

var
  bBytes:integer;
  szBuffer:array[0..512] of char; //must be big enough to keep your data.
begin
   bBytes:=sizeof(szBuffer);
   FillChar(szBuffer, bBytes, 0);
   SendMessage(Edit1.Handle,  WM_GETTEXT,  bBytes, szBuffer);
   ShowMessage(szBuffer, 'title', MB_OK);
end;

assuming you are trying to access a TEdit control in another program look atIvanov_G's code on how to obtain window Handle.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11750887
did you looked at my post ? I think it is clear enough...

var
  IE_Handle     : HWND;
  URL           : array[0..255] of Char;
begin
  ...
  SendMessage(IE_Handle, WM_GETTEXT, sizeof(URL), Integer(@URL[0]));
  Memo1.Lines.Add(String(URL));
0
 
LVL 1

Author Comment

by:din345
ID: 11750943
> did you looked at my post ? I think it is clear enough...
yes i did.

SendMessage(FindWindowEx(FindWindow('notepad', nil),  WM_GETTEXT,  bBytes, szBuffer);

[Error] Unit1.pas(34): Incompatible types: 'Integer' and 'PChar'
[Error] Unit1.pas(34): Not enough actual parameters

??

can't compile...
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 20 total points
ID: 11750968
I don't see where I used PChar... Maybe you are messing my answer with someone else.

Your code should look like this:

var
  Notepad_Handle     : HWND;
  Text                      : array[0..4096] of Char;
begin
  Notepad_Handle := FindWindowEx(FindWindow('notepad', nil);
  SendMessage(Notepad_Handle, WM_GETTEXT, sizeof(Text), Integer(@Text[0]));
  Memo1.Lines.Add(String(Text));
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question