Link to home
Start Free TrialLog in
Avatar of allie910
allie910

asked on

show that program is downloading using progressbar..?

hi all,

I use my program to download some file from a website,  sometimes the connection is very slow (well, i can't do anything about that). The problem is... if the connectiong is slow... it looks like that if my program hang. (it looks like it doesn't do anything).

my question is, is there any way that I can do to indicate that my program is still running...?? showing a progressbar maybe..??
Avatar of Deti
Deti
Flag of Poland image

Most easy way is to install THTTPGet Component to your Delphi.. and put it to a form. Then - all we have to do is that event:

procedure TfrmUpdate.HTTPGet(Sender: TObject; TotalSize, Readed: Integer);
begin
  Progress.Max := TotalSize;
  Progress.Position := Readed;
end;

And it is working... :)
Avatar of Lee_Nover
Lee_Nover

what are you using for download ? Indy ? if you're using TidHTTP then it's rather simple .. just chain in a IdConnectionIntercept and use it's OnReceive event
if you're using URLDownloadToFile then you can set a status callback
function URLDownloadToFile(Caller: IUnknown; URL: PChar; FileName: PChar; Reserved: DWORD; StatusCB: IBindStatusCallback): HResult; stdcall;
StatusCB is the param you need

if you have D7 you can use TDownloadURL class .. it's an Action with an OnDownloadProgress event
Well yeah it all depends on how you're downloading it... it sounds to me that whatever you're using is a blocking type socket and your application must be freezing everytime it waits for incoming data..

If you can't use a ProgressBar i suggest threading the code and then use a timer to display a little animation to show it's still downloading... or rewrite the way it downloads the file and use a progressbar.
Avatar of allie910

ASKER

oopss.. sorry i guess I forgot to attach my code there....

well, here is my code : (im using indy http ==> idHttp to get the file)

 HTMLContent := IdHTTP1.Get(IEAddress);

thanks :D
ASKER CERTIFIED SOLUTION
Avatar of Lee_Nover
Lee_Nover

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial