#1 2021-06-08 09:59:24

tbo
Member
Registered: 2015-04-20
Posts: 339

Changes in class TWinHttpApi function InternalRetrieveAnswer()

mORMot2, unit mormot.net.client

Could you make the following changes in class TWinHttpApi in the function InternalRetrieveAnswer():

At the first call of OnProgress pmCurrentSize should be 0 (pmCurrentSize = 0).
At the last call of OnProgress pmCurrentSize should be pmContentLength (pmCurrentSize = pmContentLength).

I want to display a form with a progress bar with the following assignment:

TWinHttpApi(FRestHttpClient.Request).OnProgress := TWinHttpProgress.DoShowAndProgress;

If the content length is not known, the marquee mode should be activated for the ProgressBar. The current implementation does not allow this.

My ideal implementation looks like this:

TWinHttpProgress = class(TObject)
strict private
  class var
    FWindowList: Pointer;
    FProgressForm: TForm;
protected
  class procedure ShowForm(pmIsMarqueeMode: Boolean);
  class procedure HideForm;
  class procedure Progress(pmCurrentSize, pmContentLength: Cardinal);
public
  class procedure DoShowAndProgress(pmSender: TWinHttpApi; pmCurrentSize, pmContentLength: Cardinal);
end;
class procedure TWinHttpProgress.DoShowAndProgress(pmSender: TWinHttpApi; pmCurrentSize, pmContentLength: Cardinal);
begin
  if pmCurrentSize = 0 then
    TWinHttpProgress.ShowForm(pmContentLength = 0)
  else if pmCurrentSize = pmContentLength then
    TWinHttpProgress.HideForm
  else
    TWinHttpProgress.Progress(pmCurrentSize, pmContentLength);
end;

Many thanks in advance.

With best regards
Thomas

Offline

#2 2021-06-08 18:01:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,350
Website

Re: Changes in class TWinHttpApi function InternalRetrieveAnswer()

TWinHttpApi.OnProgress should now be called at start and ending process.

Offline

Board footer

Powered by FluxBB