TActionList in Delphi verfügt über eine Standardaktion TDownLoadURL, die URLDownloadToFile intern verwendet. Beim Herunterladen einer Datei wird regelmäßig ein OnDownloadProgress-Ereignis generiert, sodass diese mit einem Fortschrittsbalken angezeigt werden kann.
In diesem Artikel wird beschrieben, wie Delphi TActionList zum Herunterladen von Dateien verwendet. Der Implementierungscode lautet wie folgt:
verwendet Windows, Nachrichten, Grafiken, Steuerelemente, Formulare, Dialoge, ExtActns, ActnList, StdCtrls, ComCtrls; Typ TForm1 = class(TForm) Button1: TButton; ProgressBar1: TProgressBar; procedure Button1Click( : TObject); private { Private Deklarationen }-Prozedur URL_OnDownloadProgress (Sender: TDownLoadURL; Progress, ProgressMax: Cardinal; StatusCode: TURLDownloadStatus; StatusText: String; var Cancel: Boolean) ; var Form1: TForm1; Implementierung {$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 := ExecuteTarget(nil) ; ProgressBar1.Max := 0;end;