Delphi DLL PercentDone Callbacks

The Chilkat Delphi DLL (non-ActiveX) supports callbacks starting in version 9.5.0.82, to be released in Feb 2020.   Pre-release Beta builds are available upon request.

Also see:

1) First define a function exactly as shown here.  Make sure to use the “cdecl” calling convention.

Returning a non-zero Result will cause the Chilkat method to abort.  It is important to set Result := 0 to allow the Chilkat method to continue.

function MyPercentDone(pctDone: Integer): Integer; cdecl;
begin
    Form1.ProgressBar1.Position := pctDone;
    Result := 0;
end;

2) Set the percent-done callback by calling the appropriate SetPercentDone function.   For the CkZip object it is  CkZip_SetPercentDone(zip,MyPercentDone);

Note: This example shows PercentDone events using CkZip.  The same technique applies to any Chilkat class having callbacks. 
For example, CkRest_SetPercentDone.

// Create a .zip with PercentDone callbacks.
procedure TForm1.Button1Click(Sender: TObject);
var
zip: HCkZip;
success: Boolean;
recurse: Boolean;

begin
zip := CkZip_Create();
success := CkZip_NewZip(zip,'C:/temp/out.zip');
if (success == False) then
  begin
    Memo1.Lines.Add(CkZip__lastErrorText(zip));
    Exit;
  end;

recurse := True;
success := CkZip_AppendFiles(zip,'c:/temp/someDir/*',recurse);
if (success == False) then
  begin
    Memo1.Lines.Add(CkZip__lastErrorText(zip));
    Exit;
  end;

// Setup the percent-done callback.
CkZip_SetPercentDone(zip,MyPercentDone);

// The MyPercentDone function will be called from within CkZip_WriteZipAndClose
success := CkZip_WriteZipAndClose(zip);
if (success == False) then
  begin
    Memo1.Lines.Add(CkZip__lastErrorText(zip));
    Exit;
  end;

Memo1.Lines.Add('Zip Created!');

CkZip_Dispose(zip);

end;