Registriert seit: 18. Mär 2007
Ort: Borland
556 Beiträge
Delphi 7 Enterprise
|
FTP Fortschritt > Progressbar
23. Mai 2007, 13:38
Delphi-Quellcode:
procedure TMainForm.IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
ProgressBar1.Max := AWorkCountMax;
ProgressBar1.Position := 0;
end;
procedure TMainForm.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
Var
S: String;
TotalTime: TDateTime;
H, M, Sec, MS: Word;
DLTime: Double;
begin
//Errechnen der Transfergeschwindigkeit:
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;
S := FormatFloat('0.00 KB/s', AverageSpeed);
case AWorkMode of
wmRead: StatusBar1.Panels[1].Text := 'Download speed ' + S;
wmWrite: StatusBar1.Panels[1].Text := 'Uploade speed ' + S;
end;
//Aktualisieren der Fortschrittsanzeige:
ProgressBar1.Position := AWorkCount;
end;
@Quelle: http://www.dsdt.info/tutorials/indy/?page=4
Laut diesem Code soll man sich den Fortschritt des Down-/ Uploades anzeigenlassen können sollen. Ja mein Problem dürfte nicht all zu Überraschend sein:
Wieso funktioniert mein Code nicht?
Delphi-Quellcode:
procedure TForm2.IdFTP2WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Integer);
begin
Form4.ProgressBar1.Max := AWorkCountMax;
Form4.ProgressBar1.Position := 0;
end;
procedure TForm2.IdFTP2Work(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Integer);
Var
S: String;
TotalTime: TDateTime;
H, M, Sec, MS: Word;
DLTime: Double;
begin
application.processMessages;
//Errechnen der Transfergeschwindigkeit:
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;
S := FormatFloat('0.00 KB/s', AverageSpeed);
case AWorkMode of
wmRead: Form4.StatusBar1.Panels[1].Text := 'Download speed ' + S;
wmWrite: Form4.StatusBar1.Panels[1].Text := 'Uploade speed ' + S;
end;
//Aktualisieren der Fortschrittsanzeige:
Form4.ProgressBar1.Position := AWorkCount;
end;
mfg napsterXX
|
|
Zitat
|