描述:
class ATL_NO_VTABLE CAddin :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CAddin, &CLSID_Addin>,
public ISupportErrorInfo,
public IDispatchImpl<IAddin, &IID_IAddin, &LIBID_OUTLOOKADDINLib>,
public IDispatchImpl<_IDTExtensibility2, &IID__IDTExtensibility2, &LIBID_AddInDesignerObjects>,
public IDispEventSimpleImpl<1,CAddin,&__uuidof(Office::_CommandBarButtonEvents)>,
public IDispEventSimpleImpl<2,CAddin,&__uuidof(Office::_CommandBarButtonEvents)>,
public IDispEventSimpleImpl<3,CAddin,&__uuidof(Office::_CommandBarButtonEvents)>,
public IDispEventSimpleImpl<4,CAddin,&__uuidof(Outlook::ApplicationEvents)>
{
public:
typedef IDispEventSimpleImpl</*nID =*/ 1,CAddin, &__uuidof(Office::_CommandBarButtonEvents)> CommandButton1Events;
typedef IDispEventSimpleImpl</*nID =*/ 2,CAddin, &__uuidof(Office::_CommandBarButtonEvents)> CommandButton2Events;
typedef IDispEventSimpleImpl</*nID =*/ 3,CAddin, &__uuidof(Office::_CommandBarButtonEvents)> CommandMenuEvents;
typedef IDispEventSimpleImpl</*nID =*/ 4,CAddin, &__uuidof(Outlook::ApplicationEvents)> AppEvents;
.
.
.
我在cpp文件中包含的这个h文件,在
CAddin::CommandButton1Events::DispEventAdvise((IDispatch*)m_spButton);时
报错error C2352:'ATL::IDispEventSimpleImpl<1,class CAddin,&struct __s_GUID _GUID_000c0351_0000_0000_c000_000000000046>::DispEventAdvise' : illegal call of non-static member function
期望高人指点如何解决?
解决方案1:
Compiler Error C2352
'class::function' : illegal call of non-static member function
The specified nonstatic member function was called in a static member function.
The following is an example of this error:
class X
{
public:
static void func1();
void func2();
static void func3()
{
func1(); // OK, calls static func1
func2(); // error, calls nonstatic func2
}
};
静态函数是类的成员。非静态函数是对象的成员。静态函数只能操作静态成员和静态函数,按这个思路找找,应该没问题。