#pragma once
#include ".\mysink.h"
#include "IComEvtClient.h"

namespace ComSupport
{
	class CMyListener : IComEvtClient
	{
		//CP
		CComObject<CMySink>* m_pListener;
		DWORD m_dwCockie;
		CComPtr<IConnectionPoint> m_spConnectionPoint;

		//CP interface info
		_bstr_t m_strName;//name of the connection interface
		IID m_guid;//guid of connection interface
		CComPtr<ITypeInfo> m_spTI;//type of the connection interface

		//ComEvtClient realted
		IComEvtClient2* m_pEventMgr;
		DWORD m_dwObjID;

	public:
		BOOL Create(
			IComEvtClient2* pEventMgr, 
			const CComPtr<IConnectionPoint>& spConnectionPoint,
			const CComPtr<IDispatch>& obj,
			DWORD dwObjID);
		virtual ~CMyListener();

	public://interface IComEvtClient
		virtual HRESULT OnEvent(
            /* [in] */ DISPID dispIdMember,
            /* [in] */ REFIID riid,
            /* [in] */ LCID lcid,
            /* [in] */ WORD wFlags,
            /* [out][in] */ DISPPARAMS *pDispParams,
            /* [out] */ VARIANT *pVarResult,
            /* [out] */ EXCEPINFO *pExcepInfo,
            /* [out] */ UINT *puArgErr);
	};
}