问题
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