procedure TForm1.LoadAFile(
const AFile:
string);
var
ThisFilePath, ThisFileName:
string;
begin
Form1.Caption := AFile;
mmoFilesInDirectory.Lines.Add(AFile);
end;
procedure TForm1.btnManuallyLoadAFileClick(Sender: TObject);
begin
if dlgOpen.Execute(
Handle)
then
begin
mmoFilesInDirectory.Lines.Clear;
LoadAFile(dlgOpen.FileName);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
LoadAFile(ExtractFilePath(Application.ExeName) + '
Unit1.dfm');
end;
procedure TForm1.btnGetNextFileClick(Sender: TObject);
var
ActualFilePath, NextFile:
string;
NextFileFound: Boolean;
SearchRec: TSearchRec;
begin
NextFileFound := False;
ActualFilePath := ExtractFilePath(Form1.Caption);
// Geladene Datei suchen:
if FindFirst(ActualFilePath + '
*.*', faAnyFile, SearchRec) = 0
then
begin
repeat
if not (SearchRec.Attr
and faDirectory > 0)
then
begin
if AnsiCompareText(ActualFilePath + SearchRec.
Name, Form1.Caption) = 0
then
BREAK;
end;
until FindNext(SearchRec) <> 0;
end;
// Nächste Datei nach der geladenen Datei suchen:
while FindNext(SearchRec) = 0
do
begin
if not (SearchRec.Attr
and faDirectory > 0)
then
begin
NextFile := ActualFilePath + SearchRec.
Name;
// Geladene Datei ausschließen:
if AnsiCompareText(NextFile, Form1.Caption) <> 0
then
begin
LoadAFile(NextFile);
NextFileFound := True;
BREAK;
end;
end;
end;
FindClose(SearchRec);
if not NextFileFound
then
begin
if chkStopAtEndOfDirectory.Checked
then
MessageDlg('
Ende des Verzeichnisses!', mtInformation, [mbOK], 0)
else
begin
// Suche erneut am Beginn des Verzeichnisses fortsetzen:
if FindFirst(ActualFilePath + '
*.*', faAnyFile, SearchRec) = 0
then
begin
repeat
if not (SearchRec.Attr
and faDirectory > 0)
then
begin
mmoFilesInDirectory.Lines.Add('
');
LoadAFile(ActualFilePath + SearchRec.
Name);
BREAK;
end;
until FindNext(SearchRec) <> 0;
end;
FindClose(SearchRec);
end;
end;
end;