Board index » delphi » Assigning a COM event handler - help

Assigning a COM event handler - help

Apologies.  My news client inadvertantly said my previous posting was from
"Borland".  Sigh.  I have now fixed this.
========================================
I have a form which contains a callback from an in-process server.  There
will be multiple instances of this form in the program, so I cannot
implement the callback code in the event handler class, but want to map the
event handler to a method in the form object.  This results in a "not enough
actual parameters" error.

Advise please?  Here is an extract of the relevant code:

TEventHandlerA = class(TAutoIntfObject, IFooEvents)
  procedure OnUpdateA (Value: Integer); safecall;
  end;

TFormA = class(TForm)
  private
    Callback:  TEventHandlerA;
  protected
    procedure UpdateA(Value: Integer);safecall;
  end;

TFormA.Create(Sender:TObject);
begin
..
  CallbackA := TEventHandlerA.Create(TypeLib,IFooEvents);
  CallbackA.OnUpdateA := UpdateA; //"not enough actual parameters"!!
..
end;

TFormA.UpdateA(Value: Integer);safecall;
begin
//do something
end;

HELP!

 

Re:Assigning a COM event handler - help


I have a form which contains a callback from an in-process server.  There
will be multiple instances of this form in the program, so I cannot
implement the callback code in the event handler class, but want to map the
event handler to a method in the form object.  This results in a "not enough
actual parameters" error.

Advise please?  Here is an extract of the relevant code:

TEventHandlerA = class(TAutoIntfObject, IFooEvents)
  procedure OnUpdateA (Value: Integer); safecall;
  end;

TFormA = class(TForm)
  private
    Callback:  TEventHandlerA;
  protected
    procedure UpdateA(Value: Integer);safecall;
  end;

TFormA.Create(Sender:TObject);
begin
..
  CallbackA := TEventHandlerA.Create(TypeLib,IFooEvents);
  CallbackA.OnUpdateA := UpdateA; //"not enough actual parameters"!!
..
end;

TFormA.UpdateA(Value: Integer);safecall;
begin
//do something
end;

HELP!

Re:Assigning a COM event handler - help


COM events are not similar to native Delphi events. Working with COM events
usually require knowledge of the connection-points infrastructure. One way
to simplify connection-points is to use my EventSinkImp utility. Also study
the simple examples on my site.

--
have fun
Binh Ly
http://www.techvanguards.com

Quote
"Borland" <john.fall...@home.com> wrote in message

news:3b7807ea$1_2@dnews...
Quote
> I have a form which contains a callback from an in-process server.  There
> will be multiple instances of this form in the program, so I cannot
> implement the callback code in the event handler class, but want to map
the
> event handler to a method in the form object.  This results in a "not
enough
> actual parameters" error.

Re:Assigning a COM event handler - help


Hi, Binh.  I was just about to post the solution (giving credit to your site
where I found it!) when your message arrived.

I implimented the approach described in your COM Callbacks Demo (TChatEvent,
TChatMessageEvent, etc.) and it works fine.  Thanks, as always.

Quote
"Binh Ly" <b...@castle.net> wrote in message news:3b787b35_2@dnews...
> COM events are not similar to native Delphi events. Working with COM
events
> usually require knowledge of the connection-points infrastructure. One way
> to simplify connection-points is to use my EventSinkImp utility. Also
study
> the simple examples on my site.

> --
> have fun
> Binh Ly
> http://www.techvanguards.com

> "Borland" <john.fall...@home.com> wrote in message
> news:3b7807ea$1_2@dnews...
> > I have a form which contains a callback from an in-process server.
There
> > will be multiple instances of this form in the program, so I cannot
> > implement the callback code in the event handler class, but want to map
> the
> > event handler to a method in the form object.  This results in a "not
> enough
> > actual parameters" error.

Other Threads