Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to use FindWindowEx() and WM_GETTEXT

Posted on 2004-08-09
8
Medium Priority
?
1,530 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Assisted Solution

by:alikoank
alikoank earned 60 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 60 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

783 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