使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 4905e2e7537d507f218e8e9595485e09d9f3a2b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// 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<CComSingleThreadModel>,
    public CComCoClass<CMBAddIn, &CLSID_MBAddIn>,
    public IDispatchImpl<IMBAddIn, &IID_IMBAddIn, &LIBID_mbInsideLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
    public IDispatchImpl<_IDTExtensibility2, &__uuidof(_IDTExtensibility2), &LIBID_AddInDesignerObjects, /* wMajor = */ 1>,
    public IDispEventSimpleImpl<1, CMBAddIn,&__uuidof(Office::_CommandBarButtonEvents)>
{
public:
    typedef IDispEventSimpleImpl</*nID =*/ 1, CMBAddIn, &__uuidof(Office::_CommandBarButtonEvents)> 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<Office::_CommandBarButton> m_spButton;
    CComPtr<Word::_Application>    m_spWordApp;
    CComPtr<Excel::_Application>    m_spExcelApp;
    CComPtr<MSPPT::_Application>    m_spPowerPointApp;
 
};
 
OBJECT_ENTRY_AUTO(__uuidof(MBAddIn), CMBAddIn)