Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get Form+components place ??

Posted on 1998-02-11
4
Medium Priority
?
161 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 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview
Suggested Courses

824 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