Solved

how to use FindWindowEx() and WM_GETTEXT

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

Author Comment

by:din345
ID: 11750837
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now