Thanks for testing. Now- what Delphi do you have? I have XE
I use Delphi 10.2 but in Lazarus it worked fine too.
Arrgh... I now see when this happens.
I didn't have a changed.log in my 7zip directory so it only compressed 1 file.
It ONLY happens if you have multiple files.
I also noticed that with 1 small file, sometimes the TMemo is finished and the TProgressbar lags behind.
I think the freeze might have something to do with threads.
When doing a postmessage to the form it works fine (with multiple files).
const
WM_OK = WM_USER + 1;
type
TForm1 = class(TForm)
ProgressBar1: TProgressBar;
Memo1: TMemo;
Button3: TButton;
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
procedure WMOk(var msg: TMessage); message WM_OK;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMOk(var msg: TMessage);
begin
if boolean(msg.LParam) then
Form1.ProgressBar1.Max := msg.WParam
else
Form1.ProgressBar1.Position := msg.WParam;
Form1.Memo1.Lines.Add(IntToStr(msg.WParam));
end;
function ProgressCallback(Sender: Pointer; total: boolean; value: int64): HRESULT; stdcall;
begin
Postmessage(Form1.Handle, WM_OK, value, ord(total));
Result := S_OK;
{
if total then
Form1.ProgressBar1.Max := value else
Form1.ProgressBar1.Position := value;
Form1.Memo1.Lines.Add(IntToStr(value));
}
end;
So the callback is probably run in a different thread and you can't just call Form1 variables like that from different threads.
(With thread you would normally call Synchronise for this, or implement PostMessage like I've done here)