I have a VCL form with a left panel with 24 images (imA1 .. imA24) of TImage and a right panel with 30 images (image25 .. image53) of TImage. All images are 100 x 150. These images may load pictures of 100 width, but of different height. The plan is to adapt the Image.Height and Image.Top in such a way that all pictures shown will be aligned by the bottom of the Timage frame. As each image will be loading different pictures during run time, I need to store the Image.Top positions (I have 5 rows of pictures left and right). The idea was to let this be done by a separate procedure. See code example. The issue I am facing is that apparently my use of the 'set of' functionality is incorrect, or the use of the 'in' operator. Anybody any suggestions? Thanks - Fred (One alternative I found is to store the original top position in a separate record field for all images. Perhaps easier. But why does this use of 'set of' not work?)
Type
TForm1 = class(Tform)
imA1 : TImage; // and all the others to imA24
image25 : TImage; // etc
Type
TShow = record
image : TImage;
... : .. // other records
end;
var
ShowLeft : array[1..24] of TShow;
ShowRight : array[1..30] of Tshow;
...
{ main code }
procedure PositionPicture(Im : TImage);
var
FirstRow = set of (imA1, imA2, imA3, imA4, imA5, image25, image26, image27,
image28, image29, image30);
SecondRow = set of ( .. different ones ..);
..
FifthRow = set of ( ... );
T0 : integer; // should contain the image.top value for all first row images
K,L : integer;
begin
if Im in FirstRow then T0 := 40; // THIS GOES WRONG !!!!
// 40 is for the first row
K := im.Picture.Height; // actual height of the picture now in Im
L := 150 -K; // all images have a default height of 150 pixels.
Im.Top := Im.Top + L; // move down Im by L
Im.Height := K; // Im.top is now no longer 40, so for a new picture we
end; // need to get the original position back
Procedure MainProgram;
begin
...
PositionPicture(ShowLeft[3].image); // e.g. 3 here
...
end;
Procedure TForm1.FormCreate(Sender: TObject);
begin
ShowLeft[1].image := imA1;
..
ShowLeft[24].image := imA24;
// ... etc
end;