Citation :
unit Unittelechargement;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, IdAntiFreezeBase, IdAntiFreeze, StdCtrls, ComCtrls, XPMan,DateUtils;
type
TFormtelechargement = class(TForm)
IdHTTP1: TIdHTTP;
IdAntiFreeze1: TIdAntiFreeze;
ProgressBartelechargement: TProgressBar;
Labeltailletelecharge: TLabel;
XPManifest1: TXPManifest;
Labelvitesse: TLabel;
StatusBar1: TStatusBar;
procedure IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdHTTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
private
{ Déclarations privées }
public
{ Déclarations publiques }
nbfichier:integer;
procedure recupere;
end;
var
Formtelechargement: TFormtelechargement;
fstartdate:tdate;
const
RS_Fin = 'Téléchargement terminé';
implementation
{$R *.dfm}
procedure tformtelechargement.recupere;
begin
end;
procedure TFormtelechargement.IdHTTP1Work(Sender: TObject;
AWorkMode: TWorkMode; const AWorkCount: Integer);
var ElapsedTime : Cardinal;
begin
if AWorkMode = wmRead then
begin
ProgressBartelechargement.Position := AWorkCount ;
LabelTailleTelecharge.Caption := 'Taille : '+inttostr(round(Aworkcount/1000))+' ko / '+inttostr(round(progressbartelechargement.max/1000))+' ko.';
ElapsedTime := SecondsBetween(Now,FStartDate); //Calculer le temps de téléchargement
if ElapsedTime>0 then
begin
statusbar1.Panels[1].Text:='Vitesse : '+inttostr(round((AWorkCount/1024)/ElapsedTime))+' Ko/s';
Formtelechargement.IdAntiFreeze1.process;
end;
end;
end;
procedure TFormtelechargement.IdHTTP1WorkBegin(Sender: TObject;
AWorkMode: TWorkMode; const AWorkCountMax: Integer);
begin
if AWorkMode = wmRead then
begin
ProgressBartelechargement.Max := AWorkCountMax;
ProgressBartelechargement.Position := 0 ;
statusbar1.Panels[1].Text:='Vitesse : 0 ko/s';
FStartDate := Now;
end;
end;
procedure TFormtelechargement.IdHTTP1WorkEnd(Sender: TObject;
AWorkMode: TWorkMode);
begin
if AWorkMode = wmRead then
begin
LabelTailleTelecharge.Caption := RS_Fin;
ProgressBartelechargement.Position := ProgressBartelechargement.Max;
end;
end;
end.
|