unit DownLoadForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Math, EmpfDatei, StdCtrls;
type
TLoadForm =
class(TForm)
SBDateien: TScrollBox;
BAuf: TButton;
procedure BAufClick(Sender: TObject);
private
{ Private-Deklarationen }
DownloadListe: TList;
LTimer: TTimer;
public
{ Public-Deklarationen }
constructor create(AOwner:TComponent);
reintroduce;
destructor destroy;
override;
procedure TimerUpdate(Sender:TObject);
function add(Dateiname, Dateigroesse:
string): TFDatei;
procedure del(
Index:integer);
function count:integer;
end;
var
LoadForm: TLoadForm;
implementation
{$R *.dfm}
function TLoadForm.count: integer;
begin
Result := DownloadListe.Count;
end;
constructor TLoadForm.create(AOwner: TComponent);
begin
inherited create(AOwner);
DownloadListe:=TList.Create;
LTimer := TTimer.Create(Self);
LTimer.Interval := 500;
LTimer.Enabled := false;
LTimer.OnTimer := TimerUpdate;
end;
destructor TLoadForm.destroy;
var
i: integer;
begin
for i := 1
to DownloadListe.Count
do
TFDatei(DownloadListe[i-1]).free;
DownloadListe.free;
LTimer.free;
inherited;
end;
procedure TLoadForm.TimerUpdate(Sender: TObject);
var i:integer;
begin
for i:=1
to DownloadListe.Count
do
TFDatei(DownloadListe[i-1]).Refresh;
Application.ProcessMessages;
end;
function TLoadForm.add(Dateiname, Dateigroesse:
string): TFDatei;
var
FrameDownload: TFDatei;
ID, i: integer;
begin
i := 0;
ID := 0;
while (i < DownloadListe.Count)
do
begin
ID := Max(ID, TFDatei(DownloadListe[i]).ID);
inc(i);
end;
inc(ID);
FrameDownload:=TFDatei.create(Self, ID, Dateiname, Dateigroesse);
FrameDownload.Parent:=SBDateien;
FrameDownload.Align:=alTop;
LTimer.Enabled := true;
DownloadListe.Add(FrameDownload);
for i := 1
to DownloadListe.Count
do
TFDatei(DownloadListe[i-1]).Align:=alBottom;
for i := 1
to DownloadListe.Count
do
TFDatei(DownloadListe[i-1]).Align:=alTop;
result := FrameDownload;
BAuf.Enabled:=(DownloadListe.Count > 0);
end;
procedure TLoadForm.del(
Index: integer);
begin
if (
Index >= 0)
and (
Index < DownloadListe.Count)
then begin
TFDatei(DownloadListe[
Index]).free;
DownloadListe.Delete(
Index);
LTimer.Enabled := (DownloadListe.Count > 0);
BAuf.Enabled := (DownloadListe.Count > 0);
end;
end;
procedure TLoadForm.BAufClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while (i < DownloadListe.Count)
do
begin
if TFDatei(DownloadListe[i]).Fertig
then
begin
del(i);
end
else
inc(i);
end;
end;
end.