TActionList in Delphi has a standard action TDownLoadURL, which uses URLDownloadToFile internally. When it downloads a file, it will generate an OnDownloadProgress event regularly, so that it can be displayed with a progress bar.
This article describes how Delphi uses TActionList to download files. The implementation code is as follows:
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtActns, ActnList, StdCtrls, ComCtrls; type TForm1 = class(TForm) Button1: TButton; ActionList1: TActionList; ProgressBar1: TProgressBar; procedure Button1Click(Sender : TObject); private { Private declarations } procedure URL_OnDownloadProgress (Sender: TDownLoadURL; Progress, ProgressMax: Cardinal; StatusCode: TURLDownloadStatus; StatusText: String; var Cancel: Boolean) ; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure Tform1.URL_OnDownloadProgress ;begin ProgressBar1.Max:= ProgressMax; ProgressBar1.Position:= Progress;end; procedure TForm1.Button1Click(Sender: TObject);begin with TDownloadURL.Create(self) do try URL:='//www.VeVB.COm/images/logo.gif'; FileName := 'logo.gif '; OnDownloadProgress := URL_OnDownloadProgress; ExecuteTarget(nil) ; finally Free; end; showMessage('OK'); ProgressBar1.Max := 0;end;