Solved

How to get Form+components place ??

Posted on 1998-02-11
4
138 Views
Last Modified: 2010-04-04
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.
0
Comment
Question by:CyberChild
  • 2
4 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1358943
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;

0
 

Author Comment

by:CyberChild
ID: 1358944
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 ?

0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1358945
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;
0
 
LVL 3

Accepted Solution

by:
KE earned 50 total points
ID: 1358946
Try this:

procedure TForm1.Button1Click(Sender: TObject);
Var
  MyImage : TImage;
  MyPicture : TPicture;
  i : Integer;
begin
  MyPicture := TPicture.Create;
  MyPicture.LoadFromFile('C:\WINNT\ZAPOTEC.BMP');
  MyImage := TImage.Create( self );
  MyImage.Parent := self;
  MyImage.Picture := MyPicture;
  MyImage.AutoSize := True;
  For i := 0 to width-MyImage.width-8 do begin
    MyImage.Left := i;
    MyImage.Refresh;
  end;
  For i := width-MyImage.width-8 downto 0 do begin
    MyImage.Left := i;
    MyImage.Refresh;
  end;
  MyImage.Free;
  MyPicture.Free;
end;

Well, there's a catch to this one - the image flickers if you refresh the entire form, and therefore the refresh method is only called by the image itself. This results in a tail beeing drawn after the image, but you can solve this by making a left and right column of pixels on the image in the background color of the form.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now