Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 19th, 2007, 04:48 AM
Tomi71 Tomi71 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 34 Tomi71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 11 m 34 sec
Reputation Power: 6
IdHTTP Progress?

Hey.

I'm using IdHTTP to download a file, just one simple file.

IdHTTP1.Get('address/file.zip', myFileStream);

That's the code I use. Downloading works just fine.

I would like to implement a progressbar AND download speed, so that the user knows how fast the file is coming and how much left.

Currently I use:

ProgressBar1.Progress := myFileStream.Size;

and

ProgressBar1.Max := (HTTP response to Content-Length)

Is this a good way, because this makes flicker and occasionally jumps real quick to 100% in ProgressBar and then back to what it really needs to be.

In IdHTTP's onWork event I use Application.ProcessMessages and Sleep 10 milliseconds.

I've also tried Gauge control.

Any suggestions are a-OK.

Reply With Quote
  #2  
Old August 3rd, 2010, 12:28 PM
tonermax tonermax is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2010
Posts: 3 tonermax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 8 sec
Reputation Power: 0
Max progress

Solution of MAX/POSITION for progressBar:

Code:
procedure TForm1.IdHTTPWorkBegin(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCountMax: Int64);
begin
  Screen.Cursor := crHourGlass;
  ProgressBar.Max := AWorkCountMax;
  ProgressBar.Position := 0;
end;

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


procedure TForm1.IdHTTPWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
begin
  Screen.Cursor := crDefault;
end;


is it enough? Average speed you can calculate from AWorkCount ;-)

Reply With Quote
  #3  
Old October 19th, 2012, 03:39 AM
ASAP ASAP is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 ASAP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 20 sec
Reputation Power: 0
I get this error

Quote:
[dcc32 Error] project.pas(949): E2009 Incompatible types: 'Parameter lists differ'


when I try to call WorkBegin and Work

procedure Tform2.DownloadTable;

var
ms: TMemoryStream;
path :string;

begin

ms := TMemoryStream.Create;
path := DIR; //global variable

try
with IdHttp1 do
IdHTTP1.Get(URLTAB, ms);
ms.Position := 0;
SetCurrentDir(path);
ms.SaveToFile('table.rar');
IdHttp1.OnWorkBegin := WorkBegin;
IdHttp1.OnWork := Work;

finally
ms.Free;

end;
end;

procedure TForm2.WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Int64);
begin
ProgressBar2.Max := AWorkCountMax;
end;

procedure TForm2.Work(ASender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Int64);
begin
ProgressBar2.Position := AWorkCount;
end;


Maybe I found the errors. The exact code should be:

procedure Tform2.DownloadTable;

var
ms: TMemoryStream;
path :string;

begin

ms := TMemoryStream.Create;
path := DIR; //global variable

try
with IdHttp1 do
begin
Get(URLTAB, ms);
ms.Position := 0;
SetCurrentDir(path);
ms.SaveToFile('table.rar');
OnWorkBegin := WorkBegin;
OnWork := Work;
end;

finally
ms.Free;

end;
end;

procedure TForm2.WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
begin
ProgressBar2.Max := AWorkCountMax;
end;

procedure TForm2.Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
begin
ProgressBar2.Position := AWorkCount;
end;

I can compile the exe but I stil have a problem: I can see download progress only the second time i push on the button.

Last edited by ASAP : October 19th, 2012 at 01:07 PM. Reason: maybe I found the solution

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > IdHTTP Progress?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap