Not it for me...
I have the same compilation fault
1>c:\workspaces\sandbox\console\console.cpp(19) : error C2440: 'static_cast' : cannot convert from '_atl_event_classtype *' to 'ATL::_IDispEventLocator<nID,piid> *'
this is my implementation
class ATL_NO_VTABLE CIRESSNotificationSink :
public IDispEventImpl<1,CIRESSNotificationSink,&DfsIress::DIID_IIressApplicationEvents>
{
public:
BEGIN_SINK_MAP(CIRESSNotificationSink)
SINK_ENTRY_EX(2, DfsIress::DIID_IIressApplicationEvents,1,OnLoggedIn)
END_SINK_MAP()
public:
HRESULT __stdcall OnLoggedIn(){return S_OK;};
};
Cannot see the problem - Any ideas
geekgrrl wrote:
Compile Errors using IDispEventImpl
07-Feb-08
I'm trying to learn event firing ( connection points) and event sinks.
I have a ATL COM dll with two Interfaces. The first interface simply
adds two numbers and fires an event ( using connection points) when
the numbers are added. I want the second Interface (in the same dll)
to be my event sink.
I am following the Microsoft KB Q194179 AtlEvnt.exe sample , and
implementing my sink following it's CSinkObj sample interface/class.
I've created my sink class, and followed what they are doing. I've
double-checked that I've got the correct parameters, and I'm getting
the following compile errors from VC2005:
error C2975: 'pdiid' : invalid template argument for
'ATL::IDispEventImpl', expected compile-time constant expression
error C2440: 'static_cast' : cannot convert from '_atl_event_classtype
*' to 'ATL::_IDispEventLocator<nID,piid> *'
error C2440: 'initializing' : cannot convert from 'void (__stdcall
CATNEventSink::* )(void)' to 'DISPID'
My code follows. The only think I am not doing is importing a
typelib. Should I have to? The event source and event sink are in the
same dll.
class ATL_NO_VTABLE CATNEventSink :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CATNEventSink, &CLSID_ATNEventSink>,
public IDispatchImpl<IATNEventSink, &IID_IATNEventSink,
&LIBID_AdderLib>,
public IDispEventImpl<IDC_ATNEVENTSINK, CATNEventSink,
DIID__IAddTwoNumbersEvents, &LIBID_AdderLib,/*wMajor =*/ 1, /*wMinor
=*/ 0>
{
public:
CATNEventSink()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_ATNEVENTSINK)
DECLARE_PROTECT_FINAL_CONSTRUCT()
DECLARE_NOT_AGGREGATABLE(CATNEventSink)
BEGIN_COM_MAP(CATNEventSink)
COM_INTERFACE_ENTRY(IATNEventSink)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
BEGIN_SINK_MAP(CATNEventSink)
//Make sure the Event Handlers have __stdcall calling convention
SINK_ENTRY_EX(IDC_ATNEVENTSINK, DIID__IAddTwoNumbersEvents, 1,
OnFinishedAdd)
END_SINK_MAP()
// Event handler for [id(1)] HRESULT Finished([in] LONG Result);
HRESULT __stdcall OnFinishedAdd(long result)
{
// show a message box
CComBSTR bstrCaption = OLESTR( "CATNEventSink" ) ;
//CComBSTR bstrText ;
CString buff = _T("");
buff.Format( _T("CATNEventSink : Finished Event Received - result =
%d"), result);
CComBSTR bstrText( buff ) ;
MessageBox( 0, COLE2CT(bstrText), COLE2CT(bstrCaption),
MB_SETFOREGROUND|MB_OK ) ;
return S_OK;
}
public:
};
Previous Posts In This Thread:
On Wednesday, February 06, 2008 1:30 PM
Igor Tandetnik wrote:
Re: Compile Errors using IDispEventImpl
geekgrrl <geekgrrl71@hotmail.com> wrote:
Make it &DIID__IAddTwoNumbersEvents (note the ampersand).
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
On Thursday, February 07, 2008 10:57 PM
geekgrrl wrote:
Compile Errors using IDispEventImpl
I'm trying to learn event firing ( connection points) and event sinks.
I have a ATL COM dll with two Interfaces. The first interface simply
adds two numbers and fires an event ( using connection points) when
the numbers are added. I want the second Interface (in the same dll)
to be my event sink.
I am following the Microsoft KB Q194179 AtlEvnt.exe sample , and
implementing my sink following it's CSinkObj sample interface/class.
I've created my sink class, and followed what they are doing. I've
double-checked that I've got the correct parameters, and I'm getting
the following compile errors from VC2005:
error C2975: 'pdiid' : invalid template argument for
'ATL::IDispEventImpl', expected compile-time constant expression
error C2440: 'static_cast' : cannot convert from '_atl_event_classtype
*' to 'ATL::_IDispEventLocator<nID,piid> *'
error C2440: 'initializing' : cannot convert from 'void (__stdcall
CATNEventSink::* )(void)' to 'DISPID'
My code follows. The only think I am not doing is importing a
typelib. Should I have to? The event source and event sink are in the
same dll.
class ATL_NO_VTABLE CATNEventSink :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CATNEventSink, &CLSID_ATNEventSink>,
public IDispatchImpl<IATNEventSink, &IID_IATNEventSink,
&LIBID_AdderLib>,
public IDispEventImpl<IDC_ATNEVENTSINK, CATNEventSink,
DIID__IAddTwoNumbersEvents, &LIBID_AdderLib,/*wMajor =*/ 1, /*wMinor
=*/ 0>
{
public:
CATNEventSink()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_ATNEVENTSINK)
DECLARE_PROTECT_FINAL_CONSTRUCT()
DECLARE_NOT_AGGREGATABLE(CATNEventSink)
BEGIN_COM_MAP(CATNEventSink)
COM_INTERFACE_ENTRY(IATNEventSink)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
BEGIN_SINK_MAP(CATNEventSink)
//Make sure the Event Handlers have __stdcall calling convention
SINK_ENTRY_EX(IDC_ATNEVENTSINK, DIID__IAddTwoNumbersEvents, 1,
OnFinishedAdd)
END_SINK_MAP()
// Event handler for [id(1)] HRESULT Finished([in] LONG Result);
HRESULT __stdcall OnFinishedAdd(long result)
{
// show a message box
CComBSTR bstrCaption = OLESTR( "CATNEventSink" ) ;
//CComBSTR bstrText ;
CString buff = _T("");
buff.Format( _T("CATNEventSink : Finished Event Received - result =
%d"), result);
CComBSTR bstrText( buff ) ;
MessageBox( 0, COLE2CT(bstrText), COLE2CT(bstrCaption),
MB_SETFOREGROUND|MB_OK ) ;
return S_OK;
}
public:
};
On Thursday, February 07, 2008 10:57 PM
geekgrrl wrote:
Re: Compile Errors using IDispEventImpl
That was it. I have been staring between the two all morning - and all
for the lack of ONE SINGLE CHARACTER. Grrrr.
It was blatantly obvious once you pointed it out.
Many many thanks Igor.
Submitted via EggHeadCafe - Software Developer Portal of Choice
Sending SMTP email from within BizTalk Orchestration
http://www.eggheadcafe.com/tutorials/aspnet/9dd0f346-baf9-4674-a50f-1716445b26bc/sending-smtp-email-from-w.aspx