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
Solved

Handle from Window Position, but without focus

Posted on 2006-10-20
2
199 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

838 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