IdHTTP.Post - No progress for me to display in a progressbar

前提是你 提交于 2021-02-05 11:59:47

问题


I am trying to display the progress of a POST call from my TIdHTTP component.

procedure TForm1.IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCount: Int64);
begin
ProgressBar1.Position := AWorkCount;
end;

procedure TForm1.IdHTTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCountMax: Int64);
begin
Progressbar1.Max := AWorkCountMax;
end;

However when I debug this, I land 2 times on the .Max = AWorkCountMax; line, and the first time the value is 65, and the 2nd time the value is 0.

I know it might not be necessary, since it doesent take long, but all depending on how much data is being returned, it can take long.


回答1:


begin

procedure TForm1.IdHTTPWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCountMax: Integer);
begin
   if AWorkMode = wmRead then 
   begin
      ProgressBar.Max := AWorkCountMax; 
      ProgressBar.Position := 0; 
   end;
end;

tranfert

procedure TForm1.IdHTTPWork(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCount: Integer);
begin
   if AWorkMode=wmRead then 
     ProgressBar.Position := AWorkCount;
end;

end

procedure TForm1.IdHTTPWorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
  ProgressBar.Position := 0;
end;


来源:https://stackoverflow.com/questions/6599969/idhttp-post-no-progress-for-me-to-display-in-a-progressbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!