login about faq

How do I get event callbacks in the Chilkat C++ API?

asked May 14 '13 at 11:35

chilkat's gravatar image

chilkat ♦♦

Many Chilkat C++ classes have methods with event callback capabilities. Event callbacks are implemented in an application by creating a C++ class that derives from a Chilkat "progress" class such as CkFtpProgress, and overrides one or more of the virtual event callback methods. The event callback object is provided to the Chilkat object via the put_EventCallbackObject method.

For example:

// To monitor SFTP progress, derive a class from CkSFtpProgress and
// provide implementations for AbortCheck and PercentDone:
class MySFtpProgress : public CkSFtpProgress
{ public: MySFtpProgress() { } virtual ~MySFtpProgress() { }

// Called periodically during any SFTP method that communicates with
// the server.  The HeartbeatMs property controls the frequency
// of callbacks.  The default HeartbeatMs value = 0, which disables
// AbortCheck callbacks.
void AbortCheck(bool *abort) 

    // To abort any operation while in progress, set the "abort" argument
    // equal to true, like this:
    //*abort = true;

// The PercentDone callbacks is called for any method where it it is possible
// to monitor a percentage completion, such as uploading and downloading files.
void PercentDone(int pctDone, bool *abort)
    printf("SFTP percent done: %d\n", pctDone);

    // To abort an operation while in progress, set the "abort" argument
    // equal to true, like this:
    //*abort = true;

void UploadRate(unsigned long byteCount, unsigned long bytesPerSec) 
    printf("UploadRate: byteCount = %d, bytesPerSec = %d\n",

void DownloadRate(unsigned long byteCount, unsigned long bytesPerSec) 
    printf("DownloadRate: byteCount = %d, bytesPerSec = %d\n",

void ProgressInfo(const char *name, const char *value)
    printf("%s, %s\n",name,value);


The application's event callback object is instantiated and used like this:

    CkSFtp sftp;

MySFtpProgress myProgress;

answered May 14 '13 at 11:44

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: May 14 '13 at 11:35

Seen: 1,394 times

Last updated: May 14 '13 at 11:44

powered by OSQA