Board index » delphi » WindowFromPoint... Is this possible?

WindowFromPoint... Is this possible?

I have one of my project forms above another application window.  When I
move the mouse over my form and use the WindowFromPoint function it will
return the my form's handle, understandably.  But is there a way to get
the handle of the window BEHIND my form from the mouse coordinates
(GetCursorPos) even though my form is on top of it?  Is there some method
or property I can associate with my form to make it so the WindowFromPoint
function "looks through" my form?  Thanks for ANY ideas.

 

Re:WindowFromPoint... Is this possible?


 Try the ChildWindowFromPoint API function or use EnumWindows and do the
point-testing yourself.

Rob.

De{*word*81} wrote in article <19970817170301.NAA22...@ladder02.news.aol.com>...

Quote
>I have one of my project forms above another application window.  When I
>move the mouse over my form and use the WindowFromPoint function it will
>return the my form's handle, understandably.  But is there a way to get
>the handle of the window BEHIND my form from the mouse coordinates
>(GetCursorPos) even though my form is on top of it?  Is there some method
>or property I can associate with my form to make it so the WindowFromPoint
>function "looks through" my form?  Thanks for ANY ideas.

Re:WindowFromPoint... Is this possible?


Quote
De{*word*81} wrote:

> I have one of my project forms above another application window.  When I
> move the mouse over my form and use the WindowFromPoint function it will
> return the my form's handle, understandably.  But is there a way to get
> the handle of the window BEHIND my form from the mouse coordinates
> (GetCursorPos) even though my form is on top of it?  Is there some method
> or property I can associate with my form to make it so the WindowFromPoint
> function "looks through" my form?  Thanks for ANY ideas.

You could hide your app before calling WindowFromPoint and show it again
afterwards, but this causes noticeable flicker. A similar idea is to
temporarily move it offscreen then back agin. On my system this doesn't
give any flicker. The following code shows the idea:

procedure TForm1.Button1Click(Sender: TObject);
var
  h: HWND;
  p: TPoint;
  s: string;
  oldleft: integer;
begin
  Oldleft := Left;
  Left := -(Width+100);  // anywhere offscreen will do
  GetCursorPos(p);
  h := WindowFromPoint(p);
  Left := Oldleft;
  SetLength(s, 200);
  GetWindowText(h, PChar(s), 200);
  ShowMessage(s);
end;

Chris Jobson

Re:WindowFromPoint... Is this possible?


De{*word*81} <debug...@aol.com> ?a?a?e t ??a??
<19970817170301.NAA22...@ladder02.news.aol.com>...

Quote
> I have one of my project forms above another application window.  When I
> move the mouse over my form and use the WindowFromPoint function it will
> return the my form's handle, understandably.  But is there a way to get
> the handle of the window BEHIND my form from the mouse coordinates
> (GetCursorPos) even though my form is on top of it?  Is there some method
> or property I can associate with my form to make it so the
WindowFromPoint
> function "looks through" my form?  Thanks for ANY ideas.

Iterate through all Scree.Forms in downto order and check each of it them
with FindDragTarget.

First found would be what WindwoFromPoint returns, second, third, etc would
be those BEHIND.

Wish you well.
--
Alexander Petrosyan (PAF), Moscow.
email: p...@i-connect.ru; p...@fbit.msk.su
FIDO: 2:5020/468.8
phone: (095)535-2222  12:00-21:00 MT    

Other Threads