Das war es nicht. Gleicher Fehler. Hätte mich auch gewundert, da ich den Event für den Fortschritt genauso konstruiert habe und da geht es.
Delphi-Quellcode:
type
TOnProgress =
procedure(Sender: TObject; PartFilename:
string; Total, Done:
Int64)
of object;
TFileSplitter =
class
private
...;
FOnProgress: TOnProgress;
...;
public
constructor Create;
procedure Execute;
public
...;
property OnProgress: TOnProgress
read FOnProgress
write FOnProgress;
end;
[..]
repeat
BytesRead := inFile.
Read(Buffer, Min(sizeof(Buffer), BytesToRead));
BytesWritten := outFile.
Write(Buffer, BytesRead);
Dec(BytesToRead, sizeof(Buffer));
if Assigned(OnProgress)
then
begin
OnProgress(self, PartFilename, inFile.Size, inFile.Position);
end;
until BytesToRead < 0;
Und im Programm:
Delphi-Quellcode:
type
TForm1 = class(TForm)
...;
private
{ Private-Deklarationen }
procedure SplitProgress(Sender: TObject; PartFilename: String; Total, Done: Int64);
public
{ Public-Deklarationen }
end;
[..]
procedure TForm1.SplitProgress;
begin
ProgressBar1.Max := 100;
ProgressBar1.Position := Done * 100 div Total;
Label1.Caption := PartFilename;
Application.ProcessMessages;
end;
[..]
procedure TForm1.Button1Click(Sender: TObject);
var
fs: TFileSplitter;
begin
fs := TFileSplitter.Create;
try
fs.Filename := edtFile.Text;
fs.DestFolder := edtDestFolder.Text;
fs.PartSize := StrToInt(edtPartFileSize.Text) * 1024;
fs.OnError := SplitError;
fs.OnProgress := SplitProgress;
fs.Execute;
finally
FreeAndNil(fs);
end;
end;