function Thread(p: Pointer): Integer;
var
Loop: Cardinal;
MemStream: TMemoryStream;
URL:
string;
PN:
string;
StartPage, MaxPages: Cardinal;
SB: TStatusbar;
IdHTTP: TIdHTTP;
FileExt:
string;
PDF: TPdf;
bPrint: Boolean;
Dir:
string;
btnDownload, btnCancel: TButton;
Filename:
String;
begin
Result := 0;
Loop := 0;
URL := PThreadParams(p)^.URL;
PN := PThreadparams(p)^.PN;
StartPage := PThreadParams(p)^.StartPage;
MaxPages := PThreadParams(p)^.MaxPages;
SB := PThreadParams(p)^.SB;
IdHTTP := PThreadParams(p)^.IdHTTP;
FileExt := PThreadParams(p)^.FileExt;
Pdf := PThreadParams(p)^.PDF;
bPrint := PThreadParams(p)^.bPrint;
Dir := PThreadParams(p)^.Dir;
btnDownload := PThreadParams(p)^.btnDownload;
btnCancel := PThreadParams(p)^.btnCancel;
Filename := Dir + PN + '
_' + IntToStr(Loop) + '
.' + FileExt;
for Loop := StartPage
to MaxPages
do
begin
if bCancel = 1
then
break;
MemStream := TMemoryStream.Create;
try
SB.Panels[0].Text := '
Seite: ' + IntToStr(Loop);
SB.Refresh;
try
IdHTTP.Get(
URL + IntToStr(Loop), MemStream);
except
on E:
Exception do
begin
Messagebox(0, Pointer(e.
Message), APPNAME, MB_ICONSTOP);
break;
end;
end;
MemStream.SaveToFile(Filename);
finally
FreeAndNil(MemStream);
end;
if bPrint
then
begin
//Form1.Pdf1.src := Filename;
Form1.Pdf1.LoadFile(Filename);
//PDF.printWithDialog;
end;
end;
SB.Panels[0].Text := '
Seiten:';
SB.Panels[1].Text := '
Fortschritt:';
btnDownload.Enabled := True;
btnCancel.Enabled := False;
FreeMem(p, sizeof(TThreadParams));
end;