Hola shoulder.
Te pongo una idea que tal vez te simplifique el mostrado:
Código Delphi
[-]
unit Unit2;
interface
uses Classes,StdCtrls, ExtCtrls;
type
TLabeledImage = class(TImage)
private
FLabel: TLabel;
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
property aLabel: TLabel read FLabel write FLabel;
end;
implementation
constructor TLabeledImage.Create(AOwner: TComponent);
begin
inherited;
FLabel:= TLabel.Create(Self);
end;
procedure TLabeledImage.Paint;
begin
inherited;
FLabel.Left:= Left + (Width-FLabel.Width) shr 1;
FLabel.Top := Top + Height + 5;
FLabel.Parent:= Parent;
end;
end.
Prueba:
Código Delphi
[-]
...
uses Jpeg, Unit2;
procedure TForm1.btnShowClick(Sender: TObject);
var
lbimg: TLabeledImage;
i,j,x,y: Integer;
begin
y:= 10;
for i:= 1 to 3 do
begin
x:= 10;
for j:= 1 to 4 do
begin
lbimg:= TLabeledImage.Create(Self);
lbimg.Picture.LoadFromFile('delphi.jpg');
lbimg.aLabel.Caption:= 'delphi.jpg';
lbimg.Width := 120;
lbimg.Height:= 120;
lbimg.Left := x;
lbimg.Top := y;
lbimg.Stretch:= True;
lbimg.Parent := ScrollBox1;
Inc(x, lbimg.Width + 10);
end;
Inc(y, lbimg.Height + lbimg.aLabel.Height + 10);
end;
end;
Muestra:
En las pruebas funcionó bién, pero hice el código sobre la marcha, así que seguramente podrás mejorarlo con algunos ajustes.
Saludos
