[Delphi] hoe te weten waar een tcomponent op scherm bevind

Pagina: 1
Acties:
  • 130 views sinds 30-01-2008
  • Reageer

  • tyball
  • Registratie: December 2000
  • Laatst online: 31-07 14:32
Ik wil weten waar een tcomponent(zoals een panel) relatief op het scherm bevind in pixels . Dus niet relatief tot het parent form.

  • nightowl
  • Registratie: April 2002
  • Laatst online: 14-03-2009

nightowl

always too early to sleep

Volgens mij moet je dan eerst bepalen waar het Parent-Form zich bevindt op het scherm en daarna bepaal je waar de TComponent zich bevindt in het Parent-Form. Vervolgens klein rekensommetje toch?

Ik pas in mijn jas. Mijn jas past in mijn tas. Dus ik pas in mijn tas.


  • tyball
  • Registratie: December 2000
  • Laatst online: 31-07 14:32
dat met een while lus en dan steeds .parent gaat niet werken . Dat komt door dat alles in een 'schil' zit hier op het werk die niet luisterd naar TWincontrol van de .parent. Ik moet dus echt iets anders verzinnen

Ik had dit verzonnen:


var
c : TWinControl;

begin

c := aPanel.Parent;
while c.Parent <> nil do
c := c.Parent;

end;

  • LordLarry
  • Registratie: Juli 2001
  • Niet online

LordLarry

Aut disce aut discede

Uit de help (TControl):

Translates a given point from client area coordinates to global screen coordinates.

function ClientToScreen(const Point: TPoint): TPoint;

Description

Use ClientToScreen to convert a point whose coordinates are expressed locally to the control to the corresponding point in screen coordinates. In client area coordinates (0, 0) corresponds to the upper left corner of the control's client area. In screen coordinates (0, 0) corresponds to the upper left corner of the screen.

Use ScreenToClient along with ClientToScreen to convert from one control's coordinate system to another control's coordinate system. For example,

P := TargetControl.ScreenToClient(SourceControl.ClientToScreen(P));

converts P from coordinates in SourceControl to coordinates in TargetControl.

We adore chaos because we like to restore order - M.C. Escher