// MBAddIn.h : Declaration of the CMBAddIn #pragma once #include "resource.h" // main symbols #include "mbInside_i.h" #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms." #endif using namespace ATL; // CMBAddIn extern _ATL_FUNC_INFO OnClickButtonInfo; class ATL_NO_VTABLE CMBAddIn : public CComObjectRootEx, public CComCoClass, public IDispatchImpl, public IDispatchImpl<_IDTExtensibility2, &__uuidof(_IDTExtensibility2), &LIBID_AddInDesignerObjects, /* wMajor = */ 1>, public IDispEventSimpleImpl<1, CMBAddIn,&__uuidof(Office::_CommandBarButtonEvents)> { public: typedef IDispEventSimpleImpl CommandButtonEvents; CMBAddIn() { m_strBinPath = _T(""); } DECLARE_REGISTRY_RESOURCEID(IDR_MBADDIN) BEGIN_COM_MAP(CMBAddIn) COM_INTERFACE_ENTRY(IMBAddIn) COM_INTERFACE_ENTRY2(IDispatch, _IDTExtensibility2) COM_INTERFACE_ENTRY(_IDTExtensibility2) END_COM_MAP() BEGIN_SINK_MAP(CMBAddIn) SINK_ENTRY_INFO(1, __uuidof(Office::_CommandBarButtonEvents),/*dispid*/ 0x01, OnClickButton, &OnClickButtonInfo) END_SINK_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } public: CString m_strBinPath; // IAddin public: void _stdcall OnClickButton(IDispatch* Ctrl,VARIANT_BOOL * CancelDefault); // _IDTExtensibility2 STDMETHOD(OnConnection)(IDispatch * Application, ext_ConnectMode ConnectMode, IDispatch * AddInInst, SAFEARRAY * * custom); STDMETHOD(OnDisconnection)(ext_DisconnectMode RemoveMode, SAFEARRAY * * custom); STDMETHOD(OnAddInsUpdate)(SAFEARRAY * * custom) { return E_NOTIMPL; } STDMETHOD(OnStartupComplete)(SAFEARRAY * * custom) { return E_NOTIMPL; } STDMETHOD(OnBeginShutdown)(SAFEARRAY * * custom) { return E_NOTIMPL; } private: void SendMbcFile(CString strFile); protected: CComPtr m_spButton; CComPtr m_spWordApp; CComPtr m_spExcelApp; CComPtr m_spPowerPointApp; }; OBJECT_ENTRY_AUTO(__uuidof(MBAddIn), CMBAddIn)