在 C++ clr 中继承 class
inherit class in c++ clr
我正在尝试在 Visual Studio 2017 年使用模板 CLR/Empty CLR 项目构建一个简单的项目。我已经添加了对所需命名空间的引用,但是当我尝试继承“IMessageFilter" class 在我的 class 我遇到以下错误,我该怎么办?
class实现接口成员函数"System::Windows::Forms::IMessageFilter::PreFilterMessage"失败(声明在"c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\System.Windows.Forms.dll"
#pragma once
using namespace System;
using namespace System::Windows::Forms;
ref class myClass : public IMessageFilter // this is not accepted by compiler with error
{
public:
myClass();
};
根据报错提示,您需要实现IMessageFilter接口需要的PreFilterMessage消息函数:
virtual bool PreFilterMessage(Message% message)
{
// from MSDN: return true to filter the message and stop it from being dispatched; false to allow the message to continue to the next filter or control.
return true;
};
我正在尝试在 Visual Studio 2017 年使用模板 CLR/Empty CLR 项目构建一个简单的项目。我已经添加了对所需命名空间的引用,但是当我尝试继承“IMessageFilter" class 在我的 class 我遇到以下错误,我该怎么办?
class实现接口成员函数"System::Windows::Forms::IMessageFilter::PreFilterMessage"失败(声明在"c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\System.Windows.Forms.dll"
#pragma once
using namespace System;
using namespace System::Windows::Forms;
ref class myClass : public IMessageFilter // this is not accepted by compiler with error
{
public:
myClass();
};
根据报错提示,您需要实现IMessageFilter接口需要的PreFilterMessage消息函数:
virtual bool PreFilterMessage(Message% message)
{
// from MSDN: return true to filter the message and stop it from being dispatched; false to allow the message to continue to the next filter or control.
return true;
};