Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to get Form+components place ??

Posted on 1998-02-11
4
Medium Priority
?
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

704 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