共用方式為


ATL 連接點範例

這個範例顯示所支援 IPropertyNotifySink 為輸出介面的物件:

class ATL_NO_VTABLE CConnect1 :
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CConnect1, &CLSID_Connect1>,
   public IConnectionPointContainerImpl<CConnect1>,
   public IConnectionPointImpl<CConnect1, &IID_IPropertyNotifySink>,
   public IConnect1
{
public:
   CConnect1()
   {
   }

DECLARE_REGISTRY_RESOURCEID(IDR_CONNECT1)


BEGIN_COM_MAP(CConnect1)
   COM_INTERFACE_ENTRY(IConnect1)
   COM_INTERFACE_ENTRY(IConnectionPointContainer)
END_COM_MAP()

BEGIN_CONNECTION_POINT_MAP(CConnect1)
   CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
END_CONNECTION_POINT_MAP()


   DECLARE_PROTECT_FINAL_CONSTRUCT()

   HRESULT FinalConstruct()
   {
      return S_OK;
   }

   void FinalRelease()
   {
   }

public:

};

當指定 IPropertyNotifySink 為輸出介面時,您可以使用類別 IPropertyNotifySinkCP 而不是 IConnectionPointImpl。例如:

class ATL_NO_VTABLE CConnect2 :
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CConnect2, &CLSID_Connect2>,
   public IConnectionPointContainerImpl<CConnect2>,
   public IPropertyNotifySinkCP<CConnect2>

請參閱

參考

ATL 連接點