login about faq

how can I get a disconnect event like "sftp.OnAbortCheck := sftpAbortCheck;" in ActiveX, please.

I'm using Delphi non-Active-X Version and can't find out how to catch events in that version. (sry, I'm new with that)

asked Aug 17 at 13:14

kami's gravatar image


Unfortunately, event callbacks don't exist in the non-ActiveX Delphi DLL. I don't know of a way (yet?) to call back from native C++ into a Delphi app. I would imagine there's a way to do it since the ActiveX COM infrastructure provides that ability.

Thus, at this time, there are two Delphi options: (1) The ActiveX w/ event callbacks, but the drawback is that the ActiveX DLL needs to be registered (regsvr32) on any computer where it runs, or (2) The Delphi DLL which needs no regsvr32 registration, but has no callbacks.


answered Aug 18 at 08:43

chilkat's gravatar image

chilkat ♦♦

callbacks from C++ to delphi can be done as in following example. in the example there is also a "tag"-param, which allows in the delphi-code the reentrance into the object (from __callback_Register_OnClose into TForm213.Nfy_OnClose).

hope this helps. if I can help more, please do not hesitate to contact me directly.

------------------------------ c++ code:

include "stdafx.h"

//type-definition for callback func

extern "C" typedef void ( TFktRegisterOnClose)( void * a__tag, int handle, char a_value);

//function to register callback

extern "C" __declspec(dllexport)void Register_OnClose( TFkt_Register_OnClose a_fkt, void * a_callback_tag);


extern "C" __declspec(dllexport)void DoTest( int v1, int v2);

//global defined variables - here for Demonstration

TFkt_Register_OnClose glob_fkt = (TFkt_Register_OnClose)0;

void * glob_callback_tag = (void *) 0;

void Register_OnClose( TFkt_Register_OnClose a_fkt, void * a_callback_tag)


   glob_fkt= a_fkt;
   glob_callback_tag = a_callback_tag;


void DoTest( int v1,int v2)


   int    handle = 88;

// now doing the callback

   if( glob_fkt)
         (* glob_fkt)( glob_callback_tag, handle, "some callback test");


-------------------------------- Delphi-code: unit Unit213;


uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;

type TForm213 = class(TForm)

 procedure FormCreate(Sender: TObject);


    procedure   Nfy_OnClose(Sender: TObject; handle:Integer; a_value:String);

public end;

var Form213: TForm213;


{$R *.dfm}

const DLLName= 'C:\projectstst_dlldebugtst_dll.dll';

type TFkt_Register_OnClose= procedure( a_tag:Pointer; handle:Integer; a_value:PAnsiChar); cdecl;

procedure   Register_OnClose( a_fkt:TFkt_Register_OnClose; a_tag:Pointer);  cdecl; external DLLName;
procedure   DoTest( v1:Integer; v2:Integer);    cdecl; external DLLName;

procedure __callback_Register_OnClose( a_tag:Pointer; handle:Integer; a_value:PAnsiChar); cdecl;
    frm:    TForm213;
    frm:=   TForm213( a_tag);
    frm.Nfy_OnClose( frm, handle, a_value);

procedure TForm213.Nfy_OnClose(Sender: TObject; handle:Integer; a_value:String);
    ShowMessage( a_value);

procedure TForm213.FormCreate(Sender: TObject);
    Register_OnClose( __callback_Register_OnClose, Self);

    DoTest( 2,4);



answered Aug 18 at 11:47

kami's gravatar image


(it seems, that some underscores have been deleted by copy and paste, but I think, you will get it to work. I tested with Win32 but it should also work with win64)

(Aug 18 at 11:49) kami

Thanks! I'll see what can be done, but I can't promise anything at the moment..


answered Aug 19 at 09:41

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: Aug 17 at 13:14

Seen: 463 times

Last updated: Aug 19 at 09:41

powered by OSQA