TActionList dans Delphi a une action standard TDownLoadURL, qui utilise URLDownloadToFile en interne. Lorsqu'il télécharge un fichier, il génère régulièrement un événement OnDownloadProgress, afin qu'il puisse être affiché avec une barre de progression.
Cet article décrit comment Delphi utilise TActionList pour télécharger des fichiers. Le code d'implémentation est le suivant :
utilise Windows, Messages, SysUtils, Variants, Classes, Graphiques, Contrôles, Formulaires, Boîtes de dialogue, ExtActns, ActnList, StdCtrls, ComCtrls ; tapez TForm1 = class(TForm) Button1 : TButton1 : TActionList ; : TObject); procédure privée {Déclarations privées} URL_OnDownloadProgress (Expéditeur : TDownLoadURL ; Progress, ProgressMax : Cardinal ; StatusCode : TURLDownloadStatus ; StatusText : String ; var Cancel : Boolean) ; public { Déclarations publiques } end ; var Form1 : TForm1 ; implémentation {$R *.dfm} procédure Tform1.URL_OnDownloadProgress ;début ProgressBar1.Max:= ProgressMax; Progress;fin; procédure TForm1.Button1Click(Sender: TObject);commence par TDownloadURL.Create(self) et essaie URL:='//www.VeVB.COm/images/logo.gif'; '; OnDownloadProgress := URL_OnDownloadProgress; ExecuteTarget(nil) ; enfin Free ; ProgressBar1.Max := 0;fin;