Solved

Handle from Window Position, but without focus

Posted on 2006-10-20
2
200 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
ID: 17778031
0
 
LVL 28

Accepted Solution

by:
TName earned 500 total points
ID: 17778984
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

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!

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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