Connection Points

A connectable object is one that supports outgoing interfaces. An outgoing interface allows the object to communicate with a client. For each outgoing interface, the connectable object exposes a connection point. Each outgoing interface is implemented by a client on an object called a sink.

Each connection point supports the IConnectionPoint interface. The connectable object exposes its connection points to the client through the IConnectionPointContainer interface.

This article:

See Also The Proxy Generator, IConnectionPoint and IConnectionPointContainer in the Win32 SDK


Connection Point Classes

ATL uses the following template classes to support connection points:

Back To Top


Adding Connection Points to an Object

To add a connection point to an object:

  1. Derive your class object from IConnectionPointContainerImpl and from one or more instances of IConnectionPointImpl. Each instance of IConnectionPointImpl represents a separate connection point.
  2. Add an entry in the object's COM map for IConnectionPointContainer to expose the new interface.
  3. Add a connection point map to your object declaration as follows:
    BEGIN_CONNECTION_POINT_MAP(x) 
       CONNECTION_POINT_ENTRY(iid) 
    END_CONNECTION_POINT_MAP() 

    The parameter x is the name of your class, while iid is the IID of the interface represented by the connection point.

Back To Top


Connection Point Example

This example shows an object that supports the IPropertyNotifySink connection point:

class CConnect : 
   public CComObjectRootEx<CComObjectThreadModel>, 
   public CComCoClass<CConnect, &CLSID_CConnect>, 
   public IConnectionPointContainerImpl<CConnect>
   public IConnectionPointImpl<CConnect, &IID_IPropertyNotifySink> 
{ 
public: 
   ...
   BEGIN_COM_MAP(CConnect) 
      COM_INTERFACE_ENTRY(IConnectionPointContainer) 
   END_COM_MAP() 
   BEGIN_CONNECTION_POINT_MAP(CConnect) 
      CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink) 
   END_CONNECTION_POINT_MAP() 
   ...
}; 

Note When specifying IPropertyNotifySink as an outgoing interface, you can use class IPropertyNotifySinkCP instead of IConnectionPointImpl. For example:

class CConnect : 
   public CComObjectRootEx<CComObjectThreadModel>,
   public CComCoClass<CConnect, &CLSID_CConnect>,
   public IConnectionPointContainerImpl<CConnect>,
   public IPropertyNotifySinkCP<CConnect>
{
   ...
};

Back To Top