Abbrevia progress bar

I use the open source Abbrevia components to archive some files in one Zip while this happens. I use TAbMeter Gauge to display progress.

Instead, I would rather use TProgressBar instead (supporting a standard Windows interface).

How can I use TProgressBar instead of TAbMeter? I know that I can comment on the progress myself, but when I see that the components of Abbrevia have already done this in TAbMeter, I see no reason to rewrite it.

If I could access the Position TAbMeter property, I could simulate the progress of TProgressBar by synchronizing with TAbMeter.

Here's a snippet, FileNames is a TStringList containing the names of files to archive.

procedure ArchiveFiles(SaveAs: string; ProgressBar: TAbMeter);
var
  AZipper: TAbZipper;
  i: Integer;
begin
  AZipper := TAbZipper.Create(nil);
  try
    AZipper.AutoSave := False;
    AZipper.BaseDirectory := ExtractFilePath(SaveAs);
    AZipper.ArchiveSaveProgressMeter := ProgressBar;
    AZipper.FileName := SaveAs;
    AZipper.StoreOptions := AZipper.StoreOptions + [soStripDrive, soRemoveDots]
                                                 - [soStripPath];
    AZipper.TempDirectory := GetTempDirectory;

    try
      Screen.Cursor := crHourGlass;
      ProgressBar.Visible := True;

      for i := 0 to FileList.Count - 1 do
      begin
        AZipper.AddFiles(FileList.Strings[i], 0);
      end;

    finally
      AZipper.Save;
      AZipper.CloseArchive;

      ProgressBar.Visible := False;
      Screen.Cursor := crDefault;
    end;

  finally
    AZipper.Free;
  end;
end;
+5
2

ArchiveSaveProgressMeter - . OnArchiveSaveProgress. :

procedure(Sender: TObject; Progress: Byte; var Abort: Boolean) of object;

, Position .

, , :

procedure TAbCustomZipper.DoArchiveSaveProgress(
  Sender: TObject; Progress: Byte; var Abort : Boolean);
begin
  Abort := False;
  if Assigned(FArchiveSaveProgressMeter) then
    FArchiveSaveProgressMeter.DoProgress(Progress);
  if Assigned(FOnArchiveSaveProgress) then
    FOnArchiveSaveProgress(Self, Progress, Abort);
end;

, : .


, :

procedure TMyMainForm.OnArchiveSaveProgress(
  Sender: TObject; Progress: Byte; var Abort: Boolean);
begin
  FProgressBar.Position := Progress;
end;

OnArchiveSaveProgress, , IDE. OnClick .


. Abbrevia, , . , , , , .

+5

, - , TAbProgressBar , TAbMeter. , Archive*ProgressMeter. Abbrevia Subversion AbbreviaVCL AbbreviaVCLDesign.

+1

All Articles