Registriert seit: 15. Jun 2008
Ort: Sachsen-Anhalt
109 Beiträge
Delphi XE8 Professional
|
Re: [Indy] Downloadgröße, Speed, Restzeitanzeige
9. Jul 2008, 15:54
Hallo,
habe mal vor Jahren über SMTP eine Statusanzeige fürs Versenden von eMails gemacht - vielleicht hilft es Dir weiter.
Gruß RoGa
Delphi-Quellcode:
var STime: TDateTime;
AverageSpeed: Double = 0;
BytesToTransfer: integer;
(****************************************************)
procedure TMailSendingDialog.IdSMTP1WorkBegin(Sender: TObject;
AWorkMode: TWorkMode; const AWorkCountMax: Integer);
var i: integer;
begin
SendingStatusMemo.Lines.Add('Nachricht wird versendet...');
SendingStatusMemo.Refresh;
STime := Now;
AverageSpeed := 0;
SendingProgress.MinValue := 0;
if AWorkCountMax > 0 then
SendingProgress.MaxValue := AWorkCountMax
else
begin
BytesToTransfer := BytesToTransfer + Length(MemoMessage.Text);
if MailPictureMode = 1 then
begin
BytesToTransfer := BytesToTransfer + GetFileSize(GaleryPath + ImageFileName);
end else
begin
for i := 0 to 99 do
begin
if aSendThumb[i].Visible then
BytesToTransfer := BytesToTransfer + GetFileSize(GaleryPath + aSendThumb[i].Hint);
end;
end;
SendingProgress.MaxValue := BytesToTransfer;
end;
end;
(****************************************************)
procedure TMailSendingDialog.IdSMTP1Work(Sender: TObject;
AWorkMode: TWorkMode; const AWorkCount: Integer);
var TotalTime: TDateTime;
H, M, Sec, MS: Word;
DLTime: Double;
SpeedTime: string;
begin
Application.ProcessMessages;
TotalTime := Now - STime;
DecodeTime(TotalTime, H, M, Sec, MS);
Sec := Sec + M * 60 + H * 3600;
DLTime := Sec + MS / 1000;
if DLTime > 0 then AverageSpeed := (AWorkCount / 1024) / DLTime;
//Verbleibende Zeit
if AverageSpeed > 0 then begin
Sec := Trunc(((SendingProgress.MaxValue - AWorkCount) / 1024) / AverageSpeed);
SpeedTime :=
Format('%2d:%2d:%2d', [Sec div 3600, (Sec div 60) mod 60, Sec mod 60]);
LabelTime.Caption := FormatDateTime('hh:nn:ss', StrToTime(SpeedTime));
end
else LabelTime.Caption := '';
//Geschwindigkeit
LabelSpeed.Caption := FormatFloat('0.00 KB/s', AverageSpeed);
//Statusanzeige
if AWorkCount < SendingProgress.MaxValue then
SendingProgress.Progress := AWorkCount;
end;
(****************************************************)
procedure TMailSendingDialog.IdSMTP1WorkEnd(Sender: TObject;
AWorkMode: TWorkMode);
begin
SendingProgress.Progress := 0;
SendingProgress.Refresh;
AverageSpeed := 0;
LabelTime.Caption := '';
LabelSpeed.Caption := '';
end;
Ronald
|
|
Zitat
|