var
Picturesbot: TStringList;
procedure Tform1.CreateImageList(Path: string);
var
FileList: TFileListBox;
begin
FileList := TFileListBox.Create(Self);
try
FileList.Parent := Self;
FileList.Visible := False;
FileList.Mask := '*.bmp'; // GraphicFileMask(TGraphic);
FileList.Directory := Path;
if FileList.Items.Count > 0 then
begin
Picturesbot.Assign(FileList.Items);
if (Length(Path) > 0) and (Path[Length(Path)] <> '/') then
PicPath := Path + '/'
else
PicPath := Path;
end
else
MessageDlg(Path + #10#13'没有发现标语口号文件',
mtWarning, [mbOK], 0);
finally
FileList.Free;
end;
end;
procedure Tform1.LoadNextImage;
const
CurrentImage: string = '';
var
Index: Integer;
begin
if Picturesbot.Count > 0 then
begin
repeat
Index := Random(Picturesbot.Count);
until (Picturesbot.Count <= 1) or (CurrentImage <> Picturesbot[Index]);
CurrentImage := Picturesbot[Index];
PicShow.Style :=
Random(High(TShowStyle)) + 1; //显示特效风格
PicShow.Picture.LoadFromFile(PicPath + CurrentImage);
end;
end;
procedure Tform1.ShowNextImage;
begin
if Picturesbot.Count = 0 then Exit;
if PicShow.Busy then
begin
PicShow.Stop;
end;
LoadNextImage; //装入下一个图形文件
PicShow.Clear;
PicShow.Update;
PicShow.Execute;
Timer.Interval := ShowPausesec * 1000;
end;
procedure Tform1.TimerTimer(Sender: TObject);
begin
ShowNextImage;
end;
procedure Tform1.FormCreate(Sender: TObject);
begin
if not directoryexists(picpath) then
picpath := ExtractFilePath(Application.ExeName) + 'pic';
Picturesbot := TStringList.Create; //显示图片列表
CreateImageList(picpath);
end;
procedure Tform1.FormDestroy(Sender: TObject);
begin
Picturesbot.Free;
end;