Solved

Handle from Window Position, but without focus

Posted on 2006-10-20
2
195 Views
Last Modified: 2010-04-05
I need to get a handle from control in determinated window, and this window don necessarily have a focus.

If I use WindowFromPoint(ControlPoint), they return the handle only if the control has focus.

I need to get the Handle, using coordinates relatives to ParentWindow of control, something like that:

GetHandleFromPosition(ParentHandle, PositionRelativeOnParent)

Thanks,

Felipe.
0
Comment
Question by:felipesch
  • 2
2 Comments
 
LVL 28

Assisted Solution

by:TName
TName earned 500 total points
Comment Utility
0
 
LVL 28

Accepted Solution

by:
TName earned 500 total points
Comment Utility
Ok, this works for me:

procedure TForm1.Button1Click(Sender: TObject);
var
hMain, hSub :HWND;
len:Integer;
Cap: String;
begin
 hMain:=FindWindow(nil,'TestApp');
 if hMain<>0 then begin
   hSub:=ChildWindowfromPoint(hMain, Point(200,200));
   if hSub<>0 then begin
      len := SendMessage(hSub, WM_GETTEXTLENGTH, 0, 0)+1;
      SetLength(Cap,len);
      SendMessage(hSub, WM_GETTEXT, Len, longint(Cap));
      ShowMessage(Cap);
     end;
 end;
end;
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
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…

762 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

11 Experts available now in Live!

Get 1:1 Help Now