ItemAdd event

  • Thread starter Thread starter Duncan Bates
  • Start date Start date
D

Duncan Bates

I'm trying to set up a ItemsEvents sink through ATL, but am getting compile error in the SINK_ENTRY_INFO macro.

I'm trying to log the inbox ....

error C2440: 'initializing' : cannot convert from 'ATL::_ATL_FUNC_INFO* __w64' to 'void (__stdcall C_EXTENSION::*)(void)'

My command button events work. Any tips or example code ?

// C_EXTENSION.h : Declaration of the C_EXTENSION

#pragma once

#include "resource.h" // main symbols

#include "outlook.h"

_ATL_FUNC_INFO OnButtonInfo = {CC_STDCALL,VT_EMPTY,2,{VT_DISPATCH,VT_BYREF | VT_BOOL}};

_ATL_FUNC_INFO OnItemsInfo = {CC_STDCALL,VT_HRESULT,1,{VT_DISPATCH}};

// C_EXTENSION

class ATL_NO_VTABLE C_EXTENSION :

public CComObjectRootEx<CComSingleThreadModel>,

public CComCoClass<C_EXTENSION, &CLSID_Extension>,

public IDispatchImpl<IExtension, &IID_IExtension, &LIBID_outlookLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,

public IDispatchImpl<_IDTExtensibility2, &__uuidof(_IDTExtensibility2), &LIBID_AddInDesignerObjects, /* wMajor = */ 1, /* wMinor = */ 0>,

public IDispEventSimpleImpl<1,C_EXTENSION,&__uuidof(_CommandBarButtonEvents)>,

public IDispEventSimpleImpl<2,C_EXTENSION,&__uuidof(_CommandBarButtonEvents)>,

public IDispEventSimpleImpl<3,C_EXTENSION,&__uuidof(ItemEvents)>

{

public:

C_EXTENSION();

DECLARE_REGISTRY_RESOURCEID(IDR_EXTENSION)



BEGIN_COM_MAP(C_EXTENSION)

COM_INTERFACE_ENTRY(IExtension)

COM_INTERFACE_ENTRY2(IDispatch, _IDTExtensibility2)

COM_INTERFACE_ENTRY(_IDTExtensibility2)

END_COM_MAP()

BEGIN_SINK_MAP(C_EXTENSION)

SINK_ENTRY_INFO(1,__uuidof(_CommandBarButtonEvents),0x00000001,OnClickItem1,&OnButtonInfo)

SINK_ENTRY_INFO(2,__uuidof(_CommandBarButtonEvents),0x00000001,OnClickItem2,&OnButtonInfo)

SINK_ENTRY_INFO(3,__uuidof(ItemsEvents),0x0000f001,OnItems,&OnItemsInfo)

END_SINK_MAP()



DECLARE_PROTECT_FINAL_CONSTRUCT()

HRESULT FinalConstruct();

void FinalRelease();

STDMETHOD(OnConnection)(LPDISPATCH Application, ext_ConnectMode ConnectMode, LPDISPATCH AddInInst, SAFEARRAY * * custom);

STDMETHOD(OnDisconnection)(ext_DisconnectMode RemoveMode, SAFEARRAY * * custom);

STDMETHOD(OnAddInsUpdate)(SAFEARRAY * * custom);

STDMETHOD(OnStartupComplete)(SAFEARRAY * * custom);

STDMETHOD(OnBeginShutdown)(SAFEARRAY * * custom);

void __stdcall OnClickItem1(IDispatch * Ctrl,VARIANT_BOOL * CancelDefault);

void __stdcall OnClickItem2(IDispatch * Ctrl,VARIANT_BOOL * CancelDefault);

HRESULT __stdcall OnItems(IDispatch * Ctrl);

private:

_ApplicationPtr m_pApplication;

_CommandBarButtonPtr m_pBtn1;

_CommandBarButtonPtr m_pBtn2;

_ItemsPtr m_pInbox;

};

OBJECT_ENTRY_AUTO(__uuidof(Extension), C_EXTENSION)
 
Change ur declaration for
_ATL_FUNC_INFO OnButtonInfo = ...
as
extern _ATL_FUNC_INFO OnButtonInfo = ...
I thing it works without error.
Enjoy.
 
Back
Top