Archived Forum Post

Index of archived forum posts

Question:

FTP2 OngetProgress

Oct 31 '13 at 10:55

I am using the FTP2 component and want to monitor download progress, but the event doesn't seem to be firing. I'm using the example from the website (Delphi)

FTPClient:= TChilkatFTP2.Create(nil);

FTPClient.OnGetProgress := ChilkatFtp21GetProgress; // hook into the callback

procedure TUpdateManager.ChilkatFtp21GetProgress(ASender: TObject; pctDone: Integer);

begin

fProgressFrm1.ProgressBar1.Position := pctDone;

end;

Any ideas?


Answer

This is how it should look:

unit Unit1;

interface

uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, CHILKATFTP2Lib_TLB, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.OleCtrls;

type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; ProgressBar1: TProgressBar; procedure Button1Click(Sender: TObject); procedure ftpPercentDone(ASender: TObject; percentDone: Integer); private { Private declarations } public { Public declarations } end;

var Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ftpPercentDone(ASender: TObject; percentDone: Integer); begin ProgressBar1.Position := percentDone; end;

procedure TForm1.Button1Click(Sender: TObject); var success: Integer; ftp: TChilkatFtp2; localFilename: String; remoteFilename: String; begin ftp := TChilkatFtp2.Create(Self);

ftp.OnGetProgress := ftpPercentDone;

... ...


Answer

Thanks for the reply. I've changed the create to 'Self' but it makes no difference. Still no callback being fired.

Could it be that it doesn't work because I'm using an older version of Delphi (5)?


Answer

I just needed to add AutoGetSizeForProgress := 1; and it worked fine.

Thanks for the other pointers. All happy now!