Hola Maria.
En ese caso creo que sería más sencillo trabajar todo en un form.
Poné un
TScrollBox, un
TImage, un
TTimer y un
TPanel donde irán un
TCheckBox (muestra aleatoria) y dos
TButton (Start/Stop). El ejemplito es muy simple y lo hice sin mucho detalle, pero seguro que podrás usarlo como base para algo más elaborado y optimizado.
La pantalla queda así:
El código:
Código Delphi
[-]
implementation
uses contnrs, jpeg;
var
ObjList: TObjectList;
procedure TForm1.ShowImage(AImage: TImage);
begin
Image1.Picture:= nil;
Image1.Picture:= AImage.Picture;
end;
procedure TForm1.ImageClick(Sender: TObject);
begin
ShowImage(TImage(Sender));
end;
procedure TForm1.BuscarImagenes(const Ruta: string);
var
SR: TSearchRec;
Img: TImage;
E: string;
n: Integer;
begin
if FindFirst(Ruta + '\*.*', faAnyFile, SR) = 0 then
begin
n:= 0;
repeat
E:= ExtractFileExt(SR.Name);
if (E='.jpg')or(E='.jpeg')or(E='.bmp')or(E='.emf')or(E='.wmf') then
begin
Img:= TImage.Create(Self);
ObjList.Add(Img);
with TImage(ObjList.Items[n]) do
begin
Height:= 80;
Width:= 80;
Left:= 120 * n + 10;
Top := 10;
Stretch:= True;
Picture.LoadFromFile(Ruta+'\'+SR.Name);
Parent:= ScrollBox1;
OnClick:= ImageClick;
Inc(n);
end;
end
until FindNext(SR) <> 0;
FindClose(SR)
end
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
Timer1.Enabled:= False;
ObjList:= TObjectList.Create;
BuscarImagenes('C:\RUTA_A_TUS_IMAGENES')
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Inc(FImgCount);
if CheckBoxRnd.Checked then
FImgCount:= Random(ObjList.Count)
else if FImgCount = ObjList.Count then
FImgCount:= 0;
ShowImage(TImage(ObjList.Items[FImgCount]));
end;
procedure TForm1.btnStartClick(Sender: TObject);
begin
if CheckBoxRnd.Checked then
FImgCount:= Random(ObjList.Count)
else
FImgCount:= 0;
Timer1.Enabled:= True;
ShowImage(TImage(ObjList.Items[FImgCount]));
end;
procedure TForm1.btnStopClick(Sender: TObject);
begin
Timer1.Enabled:= False;
end;
end.
Saludos.