Indicating a progress
All ECL streams provide a convenient feature allowing developer to display a progress during some potentially slow operations, such as encrypting/decrypting a file, changing compression level, reading and writing a large portion of data, calling LoadFromFile and SaveToFile functions.
To provide user a feedback about the progress of the above operations, you should do the following:
-
Write an event handler that will display the current progress of a process using a progress bar.
-
Assign the above event handler to the ECL stream OnProgress event.
The following example shows how to display the current progress while loading and compressing a file.
Example:
procedure TMainForm.CountProgress(Sender: TObject; PercentDone: Real);
begin
ProgressBar.Progress := Round(PercentDone);
Application.ProcessMessages;
end;
procedure TMainForm.Button1Click(Sender: TObject);
var
CompFS: TECLFileStream;
begin
CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmCreate, '', ppmMax);
CompFS.OnProgress := CountProgress;
CompFS.LoadFromFile('c:\test.txt');
CompFS.Free;
end;
|