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>