catch ATL COM event in MFC app
Hi,
I have a ATL COM object which fire event through connection point. I
want to catch the event in my MFC application and handle it. I followed
the MSDN aticle to do this. But I got compiling error says
"error C2146: syntax error : missing ';' before identifier
'DISP_FUNCTION_ID'
fatal error C1004: unexpected end of file found
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q181/8/45.asp&NoWebContent=1
Can anyone tell me what's wrong? I am new to these. Do I need to do
something, say add the .idl file to the MFC project before I following
the instructions in the article? Here is some of my code...
//idl file
........
library THUMBSCBLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(E381D6C4-3E26-4d02-A360-22BCC0399E98),
helpstring("_IExtractEvent Interface")
]
dispinterface _IExtractEvent
{
properties:
methods:
[id(1), helpstring("method OnExtractImage")] HRESULT
OnExtractImage([in, out] LONG *pHBmpThumbnail );
};
[
uuid(B3A3E4E4-08BE-4ad2-9333-E8958FA1E00D),
helpstring("IconExtractor Class")
]
coclass ScribbleExtractor
{
[default] interface IScribbleExtractor;
[default, source] dispinterface _IExtractEvent;
};
};
// CEventSink file
IMPLEMENT_DYNCREATE(CEventSink, CCmdTarget)
CEventSink::CEventSink()
{
EnableAutomation();
}
CEventSink::~CEventSink()
{
}
void CEventSink::OnFinalRelease()
{
// When the last reference for an automation object is released
// OnFinalRelease is called. The base class will automatically
// deletes the object. Add additional cleanup required for your
// object before calling the base class.
CCmdTarget::OnFinalRelease();
}
BEGIN_MESSAGE_MAP(CEventSink, CCmdTarget)
//{{AFX_MSG_MAP(CEventSink)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CEventSink, CCmdTarget)
//{{AFX_DISPATCH_MAP(CEventSink)
// NOTE - the ClassWizard will add and remove mapping macros here.
DISP_FUNCTION_ID(CEventSink,"ExtractThumbnail",1,OnExtractImage,VT_I4,VT_BYREF|VT_I4)
// DISP_FUNCTION_ID(CMySink,"ExtractThumbnail",1,OnExtractImage,VTS_I4,VTS_I4)
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
// Note: we add support for IID_IEventSink to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .ODL file.
// {30D42B05-0C68-47F1-8216-F96B3B10332D}
static const IID IID__IExtractEvent =
{ 0x30d42b05, 0xc68, 0x47f1, { 0x82, 0x16, 0xf9, 0x6b, 0x3b, 0x10,
0x33, 0x2d } };
BEGIN_INTERFACE_MAP(CEventSink, CCmdTarget)
INTERFACE_PART(CEventSink, IID__IExtractEvent, Dispatch)
END_INTERFACE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEventSink message handlers