Board index » delphi » More than 1 Event-Interface for a coclass possible ?

More than 1 Event-Interface for a coclass possible ?

Hello,

        is it possible to create a coclass with more than one outgoing
event interface or do I have do put all event methods in one interface ?
How should I write the EventSinkChanged method to enable the coclass to
do this ?

Thank you and greetings from Cologne
  Chris

-------------------------------------------------------
Chris Gnther
chr...@netcologne.de or g...@ifacs.de
-------------------------------------------------------

 

Re:More than 1 Event-Interface for a coclass possible ?


Do you mean more than one Event interface or more than one client for a
given interface?  You can do both.  The create more than one interface
(which is what it sounds like you want to do), assuming you're using the
TConnectionPoints object to implement the IConnectionPointContainer
interface, write a method that matches the TConnectEvent signature (ie.
procedure (const Sink: IUnknown; Connecting: Boolean) of object).  Then
create a new TConnectionPoint for each event interface using
TConnectionPoints.CreateConnectionPoint,  passing a pointer to the
appropriate ConnectEvent method as the OnConnect parameter.  TAutoObject has
a default EventConnect method that is what gets passed when using the Wizard
to create an auto object with events or an ActiveX control, which calls
EventSinkChanged, but you don't have to use this default event, or you can
use it for one of your interfaces, but not the other.

If what you want to do is attach multiple clients to a single event
interface, you need to use the OnConnect event, and add the clients to a
list.  Then when an event occurs, you have to loop through the list and fire
the event in each client.  When creating the ConnectionPoint, you have to
use ckMulti as the ConnectionKind parameter to tell the ConnectionPoint
object that it accepts multiple clients.

Regards,
Stuart

Quote
Chris Gnther wrote in message <3631876F.712AA...@netcologne.de>...
>Hello,

> is it possible to create a coclass with more than one outgoing
>event interface or do I have do put all event methods in one interface ?
>How should I write the EventSinkChanged method to enable the coclass to
>do this ?

>Thank you and greetings from Cologne
>  Chris

>-------------------------------------------------------
>Chris Gnther
>chr...@netcologne.de or g...@ifacs.de
>-------------------------------------------------------

Other Threads