Solved

how to use FindWindowEx() and WM_GETTEXT

Posted on 2004-08-09
8
1,482 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month4 days, 23 hours left to enroll

635 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