Delphi用TActionList實現(xiàn)下載文件的方法
Delphi中的TActionList有個標(biāo)準(zhǔn)動作TDownLoadURL,內(nèi)部是使用的URLDownloadToFile,它下載文件時會定時產(chǎn)生OnDownloadProgress 事件,這樣就可以用進(jìn)度條顯示。
本文講述了Delphi用TActionList實現(xiàn)下載文件的方法,實現(xiàn)代碼如下所示:
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.jb51.net/images/logo.gif'; FileName := 'logo.gif'; OnDownloadProgress := URL_OnDownloadProgress; ExecuteTarget(nil) ; finally Free; end; showMessage('OK'); ProgressBar1.Max := 0; end;
欄 目:Delphi
下一篇:Delphi實例演示Rect、Bounds生成TRect的區(qū)別
本文標(biāo)題:Delphi用TActionList實現(xiàn)下載文件的方法
本文地址:http://mengdiqiu.com.cn/a1/Delphi/8628.html
您可能感興趣的文章
- 01-10在Delphi實現(xiàn)在數(shù)據(jù)庫中存取圖像的圖文演示無錯
- 01-10delphi建立、讀取、存貯INI文件的方法《三》
- 01-10Delphi Command模式
- 01-10delphi 正弦曲線圖
- 01-10delphi建立、讀取、存貯INI文件的方法《二》
- 01-10插件管理框架 for Delphi(二)
- 01-10插件管理框架 for Delphi(一)
- 01-10Delphi中判斷文件是否為文本文件的函數(shù)
- 01-10delphi中一個值得大家來考慮的DLL問題
- 01-10初探Delphi中的插件編程


閱讀排行
本欄相關(guān)
- 01-10在Delphi實現(xiàn)在數(shù)據(jù)庫中存取圖像的圖
- 01-10delphi建立、讀取、存貯INI文件的方法
- 01-10delphi 正弦曲線圖
- 01-10Delphi Command模式
- 01-10delphi建立、讀取、存貯INI文件的方法
- 01-10插件管理框架 for Delphi(二)
- 01-10插件管理框架 for Delphi(一)
- 01-10Delphi中判斷文件是否為文本文件的函
- 01-10delphi中一個值得大家來考慮的DLL問題
- 01-10初探Delphi中的插件編程
隨機(jī)閱讀
- 01-11ajax實現(xiàn)頁面的局部加載
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-10C#中split用法實例總結(jié)
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-10delphi制作wav文件的方法
- 04-02jquery與jsp,用jquery