Link to home
Start Free TrialLog in
Avatar of CyberChild
CyberChild

asked on

How to get Form+components place ??

I want to make a component that moves over the form, from left to right and back again.
I want to use Timage.

How do I get the place of the component and the place and the width of the form the component is placed on.
Avatar of ronit051397
ronit051397

Place a TImage and run this code:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('Form X position, relative to the screen is: '+InttoStr(Top));
  ShowMessage('Form Y position, relative to the screen is: '+InttoStr(Left));
  ShowMessage('Form width is: '+InttoStr(Width));
  with Image1 do
  begin
    ShowMessage('Image X position, relative to the form is: '+InttoStr(Top));
    ShowMessage('Image Y position, relative to the form is: '+InttoStr(Left));
  end;
end;

Avatar of CyberChild

ASKER

Thanks for the answer, but it's not what I really need I think.

I want to use Timage as component and want to make adjustments to it.

The component does not know the FormName, until it's placed on an Form.

How can I get the FormName ?

How can I get the Form place X and Y ?

How can I get the component place X and Y ?

with TForm(Image1.Owner) do
begin
  Showmessage('form name is '+Name);
  ShowMessage('Form X position, relative to the screen is:    '+InttoStr(Top));
  ShowMessage('Form Y position, relative to the screen is:    '+InttoStr(Left));
end;
ASKER CERTIFIED SOLUTION
Avatar of KE
KE

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial