FTP 顯示下載進度 |
缺席
|
max5020
資深會員 ![]() ![]() ![]() ![]() ![]() 發表:30 回覆:277 積分:321 註冊:2003-06-04 發送簡訊給我 |
function Download_New(const FileName, Path, IP, User, Pass: String; const FileNew: String=''; const FileSize: Integer=0): Boolean; var IdFTP1: TIdFTP; fs: TFileStream; sf, sfn: String; xForm: TForm; xPanel: TPanel; procedure CreateTempForm(const FileName: String); begin xForm:= TForm.Create(Application); xForm.Caption:= 'File Download'; xForm.Position:= poDesktopCenter; xPanel:= TPanel.Create(xForm); xPanel.Parent:= xForm; xPanel.Caption:= ''; end; procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); begin xPanel.Caption:= 'Download ... ' IntToStr(AWorkCount) ' / ' IntToStr(FileSize) ' Bytes'; Application.ProcessMessages; end; procedure FreeFTP; begin IdFtp1.Disconnect; IdFtp1.Free; end; begin if FileNew='' then sfn:= FileName else sfn:= ExtractFilePath(FileName) FileNew; if FileSize>0 then CreateTempForm(FileName); Result:= false; IdFtp1:= TIdFTP.Create(xForm); if FileSize>0 then IdFtp1.OnWork:= IdFTP1Work; <--- 這行出錯 Error ... Incompatible types: 'method pointer and regular procedure' 請問要如何指定 onWork事件?? ps. 我想把FTP-Download寫成Function, 又要顯下載檔案進度 |
syntax
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
----> Error ... Incompatible types: 'method pointer and regular procedure'
英文看不懂嗎? 他就是跟你說,你必需將IdFTP1Work 變成 TForm 的方法 procedure TForm.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); begin xxxxxxxxxx end; ===================引 用 max5020 文 章=================== function Download_New(const FileName, Path, IP, User, Pass: String; const FileNew: String=''; const FileSize: Integer=0): Boolean; var IdFTP1: TIdFTP; fs: TFileStream; sf, sfn: String; xForm: TForm; xPanel: TPanel; procedure CreateTempForm(const FileName: String); begin xForm:= TForm.Create(Application); xForm.Caption:= 'File Download'; xForm.Position:= poDesktopCenter; xPanel:= TPanel.Create(xForm); xPanel.Parent:= xForm; xPanel.Caption:= ''; end; procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); begin xPanel.Caption:= 'Download ... ' IntToStr(AWorkCount) ' / ' IntToStr(FileSize) ' Bytes'; Application.ProcessMessages; end; procedure FreeFTP; begin IdFtp1.Disconnect; IdFtp1.Free; end; begin if FileNew='' then sfn:= FileName else sfn:= ExtractFilePath(FileName) FileNew; if FileSize>0 then CreateTempForm(FileName); Result:= false; IdFtp1:= TIdFTP.Create(xForm); if FileSize>0 then IdFtp1.OnWork:= IdFTP1Work; <--- 這行出錯 Error ... Incompatible types: 'method pointer and regular procedure' 請問要如何指定 onWork事件?? ps. 我想把FTP-Download寫成Function, 又要顯下載檔案進度 |
max5020
資深會員 ![]() ![]() ![]() ![]() ![]() 發表:30 回覆:277 積分:321 註冊:2003-06-04 發送簡訊給我 |
function Download_New(const FileName, Path, IP, User, Pass: String;
const FileNew: String=''; const FileSize: Integer=0): Boolean; var IdFTP1: TIdFTP; fs: TFileStream; sf, sfn: String; xForm: TForm; xPanel: TPanel; procedure CreateTempForm(const FileName: String); begin -----> xForm:= TForm.Create(Application); xForm.Caption:= 'File Download'; xForm.Position:= poDesktopCenter; -----> 您是指這個Form1嗎?? -----> 我是想將IdFTP1Work放在這個自己Create的xForm上面 xPanel:= TPanel.Create(xForm); xPanel.Parent:= xForm; xPanel.Caption:= ''; end; procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); begin xPanel.Caption:= 'Download ... ' IntToStr(AWorkCount) ' / ' IntToStr(FileSize) ' Bytes'; Application.ProcessMessages; end; procedure FreeFTP; begin IdFtp1.Disconnect; IdFtp1.Free; end; |
max5020
資深會員 ![]() ![]() ![]() ![]() ![]() 發表:30 回覆:277 積分:321 註冊:2003-06-04 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |