Delphi ActiveX Event Handling

ActiveX event callbacks can be used to get progress information for lengthy operations, especially for API calls involving communications with servers, such as FTP, SFTP (SSH), IMAP, POP3, SMTP, HTTP, etc.

To use an ActiveX in Delphi, the component must be “imported”. This generates wrapper files (TLB.pas) in the “imports” directory, and may also install icons on the component palettte.

The Chilkat components are non-visual. There are two ways of creating an instance of a Chilkat object: (1) drag and drop the icon from the palette onto the form. The non-visual object will be seen as a small box on the form. The component may be selected, and the events can be obtained from the object inspector. (2) The recommended technique for instantiating a Chilkat object is to do so dynamically (do not drag and drop onto the form). In this case, you can go to the generated TLB.pas file and locate the event signatures (i.e. functions). Write your own method that has the same function signature, and point the relevant event property to your new method.

For example, here are the event signatures in the TLB.pas for Chilkat FTP2:

  TChilkatFtp2PutProgress = procedure(ASender: TObject; pctDone: Integer) of object;
  TChilkatFtp2GetProgress = procedure(ASender: TObject; pctDone: Integer) of object;
  TChilkatFtp2AbortCheck = procedure(ASender: TObject; out abort: Integer) of object;
  TChilkatFtp2BeginDownloadFile = procedure(ASender: TObject; const path: WideString; 
                                                              out skip: Integer) of object;
  TChilkatFtp2EndDownloadFile = procedure(ASender: TObject; const path: WideString; 
                                                            numBytes: Integer) of object;
  TChilkatFtp2VerifyDownloadDir = procedure(ASender: TObject; const path: WideString; 
                                                              out skip: Integer) of object;
  TChilkatFtp2BeginUploadFile = procedure(ASender: TObject; const path: WideString; 
                                                            out skip: Integer) of object;
  TChilkatFtp2EndUploadFile = procedure(ASender: TObject; const path: WideString; numBytes: Integer) of object;
  TChilkatFtp2VerifyUploadDir = procedure(ASender: TObject; const path: WideString; 
                                                            out skip: Integer) of object;
  TChilkatFtp2VerifyDeleteDir = procedure(ASender: TObject; const path: WideString; 
                                                            out skip: Integer) of object;
  TChilkatFtp2VerifyDeleteFile = procedure(ASender: TObject; const path: WideString; 
                                                             out skip: Integer) of object;

Tags :