Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding absolute screen position of a component

1,643 views
Skip to first unread message

John Antoniewicz

unread,
Jun 22, 1998, 3:00:00 AM6/22/98
to

Hello,

I am using Delphi 3.02 pro in Windows 95. What I would like to is to have
a Delphi application's open up a Delphi Dialog/Input box to the left and
bottom of the pressed button inside of main form.

Thank you,
John


Alex Simonetti

unread,
Jun 22, 1998, 3:00:00 AM6/22/98
to

procedure TForm1.Button1Click(Sender: TObject);
var
ptButton : TPoint;
AbsPos : TPoint;
begin
if not (Sender is TWinControl) then exit;
ptButton.y := TWinControl(Sender).height;
ptButton.x := 0;
AbsPos := TWinControl(Sender).ClientToScreen(ptButton);
end;


After the routine is run, AbsPox.X and AbsPos.Y hold the values you want.

The trick here is the method ClientToScreen, which converts a controls
TPoint coordinate to absolute (screen) coordinate.

Yours,
- - - - - - - - - - - - - - - - - - - - - - -
Alex Simonetti Abreu
Belo Horizonte, MG, Brazil
Check out Resource Explorer --- The best of its kind.
Athena's Home: http://www.bhnet.com.br/~simonet
- - - - - - - - - - - - - - - - - - - - - - -
John Antoniewicz wrote in message <6mm7eh$hh...@forums.borland.com>...

Ralph Friedman (TeamB)

unread,
Jun 22, 1998, 3:00:00 AM6/22/98
to

John:

Take a look at the ClientToScreen and ScreenToClient functions.

--
Regards
Ralph (TeamB)
Herrsching, Germany

John Antoniewicz

unread,
Jun 22, 1998, 3:00:00 AM6/22/98
to

Thank you for your suggestion.

Thank you,
John


0 new messages