login about faq

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?

asked Oct 29 '13 at 08:19

Malden's gravatar image

Malden
1111

edited Oct 31 '13 at 09:45

chilkat's gravatar image

chilkat ♦♦
11.8k316358420


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;

... ...

link

answered Oct 31 '13 at 09:42

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

The "Self" in the TChilkatFtp2.Create is probably the important thing you are missing.

(Oct 31 '13 at 09:44) chilkat ♦♦

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)?

link

answered Oct 31 '13 at 10:23

Malden's gravatar image

Malden
1111

Maybe. I tested the exact code I provided using Delphi XE2 and it worked OK for me..

(Oct 31 '13 at 10:24) chilkat ♦♦

Also, make sure you're using the latest version of Chilkat.

(Oct 31 '13 at 10:25) chilkat ♦♦

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

Thanks for the other pointers. All happy now!

link

answered Oct 31 '13 at 10:55

Malden's gravatar image

Malden
1111

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×131
×56
×19
×1

Asked: Oct 29 '13 at 08:19

Seen: 1,069 times

Last updated: Oct 31 '13 at 10:55

powered by OSQA