Solved

How to get Form+components place ??

Posted on 1998-02-11
4
146 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to build JSON File in Delphi 6 3 46
Firemonkey DbLookupComboBox equivalent ? 2 56
Delphi problems to abort a printjob 9 25
How to make Sign in, using Clientdataset? 1 28
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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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