Solved

How to get Form+components place ??

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Dbf export problem to a Visual Foxpro application 6 189
Simple Delphi Question 9 90
Connection between libmysql.dll and MySQL Versions 7 99
RESTRequest Parameter 4 31
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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