![]() ![]() ![]() |
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:
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
{ create compressed file }
CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmCreate, '', ppmMax);
{ assign event handler }
CompFS.OnProgress := CountProgress;
{ load and compress data from test.txt file}
CompFS.LoadFromFile('c:\test.txt');
{ close compressed file }
CompFS.Free;
end;