Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Handle from Window Position, but without focus

Posted on 2006-10-20
2
Medium Priority
?
205 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 1500 total points
ID: 17778031
0
 
LVL 28

Accepted Solution

by:
TName earned 1500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

972 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