Recent

Author Topic: how to set all images proportional?  (Read 1999 times)

NoReason

  • New Member
  • *
  • Posts: 21
how to set all images proportional?
« on: December 16, 2018, 08:05:25 am »
I try something like this but it wont work.


var
  i:integer;
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  for i:=1 to 50 do
    Image[ i].Proportional:=true;

end;

end.
« Last Edit: December 16, 2018, 10:20:42 am by NoReason »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: how to set all images proportional?
« Reply #1 on: December 16, 2018, 10:28:58 am »
You must also set Stretch to true:
Code: Pascal  [Select][+][-]
  1. for i:=1 to 50 do begin
  2.   Image[i].Stretch := true;
  3.   Image[i].Proportional := true;
  4. end;

NoReason

  • New Member
  • *
  • Posts: 21
Re: how to set all images proportional?
« Reply #2 on: December 16, 2018, 10:33:00 am »
You must also set Stretch to true:
Code: Pascal  [Select][+][-]
  1. for i:=1 to 50 do begin
  2.   Image[i].Stretch := true;
  3.   Image[i].Proportional := true;
  4. end;


but i got porblem identifier not fount "image".

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: how to set all images proportional?
« Reply #3 on: December 16, 2018, 10:49:09 am »
My post was a modification of your posted code. I don't know anything else about your code. Without showing more nobody can help you.

NoReason

  • New Member
  • *
  • Posts: 21
Re: how to set all images proportional?
« Reply #4 on: December 16, 2018, 10:54:42 am »
okay, i found, should type (FindComponent('Image' + IntToStr(i)) as TImage).Proportional:=true;

thats work


thanks anyway

jamie

  • Hero Member
  • *****
  • Posts: 6133
Re: how to set all images proportional?
« Reply #5 on: December 16, 2018, 04:24:09 pm »
For future reference that works fine if they have names. using the designer that is true however, in the case
if doing dynamic creation of that, if you don't set that name then you could be up a creek without a paddle!

Now, you could enumerate the list looking for the Timage Class name instead! That will return all instances of child
Timages without the need for numbering added.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018