Jeff
Jeff

Reputation: 12183

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

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.

Upvotes: 1

Views: 4234

Answers (1)

Hugues Van Landeghem
Hugues Van Landeghem

Reputation: 6808

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;

Upvotes: 1

Related Questions