Solved

how to use FindWindowEx() and WM_GETTEXT

Posted on 2004-08-09
8
1,462 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

829 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