ATL Assert

D

Duncan Bates

ATL's DispCallFunc asserts with the E_INVALIDARG on the OnItems event in the following code. Any suggestion on what I'm doing wrong ?

My button events work fine, but my items event don't. All events are setup using the DispEventAdvise correctly, but when a folder add is done the assert happens.
// 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(ItemsEvents)>
{

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)



Duncan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top