MFC应用程序中的C#控件

时间:2021-06-29 15:51:01

I am responsible for the User Interface of an application written completely in Visual C++ using MFC and some third-part controls. I would like to use C# (WinForms or even better WPF) to improve the application look&feel.

我负责使用MFC和一些第三方控件完全用Visual C ++编写的应用程序的用户界面。我想使用C#(WinForms甚至更好的WPF)来改善应用程序的外观和感觉。

I would like some advices about how to do it. Links, articles, examples...

我想知道如何做到这一点。链接,文章,例子......

Right now the user interface is isolated in a single project and I don't want to compile the whole module with CLR. So how do I have to manage that from the architectural point of view?

现在用户界面被隔离在一个项目中,我不想用CLR编译整个模块。那么我如何从架构的角度来管理它呢?

I have already looked at the Internet for the subject and read MSDN information. I would like more detailed information...is it convinient? pros/cons? have you used this approach successfully in a "big" application? I don't want to compile the whole ui project with CLR...can I just have all the .NET code in a isolated project and call it from the ui project? what's the best way to do it?

我已经查看了该主题的Internet并阅读了MSDN信息。我想了解更详细的信息......它是否方便?优点缺点?你有没有在“大”的应用程序中成功使用这种方法?我不想用CLR编译整个ui项目...我可以将所有.NET代码放在一个独立的项目中并从ui项目中调用它吗?什么是最好的方法呢?

Thanks in advance.

提前致谢。

3 个解决方案

#1


1  

A good starting point is the Win32 and WPF interop page on MSDN.

一个很好的起点是MSDN上的Win32和WPF互操作页面。

#2


1  

I found this codeproject article gave a good introduction to the subject of mixing mfc / winforms code.

我发现这个代码项目文章很好地介绍了混合mfc / winforms代码的主题。

#3


1  

When faced with the same problem, I made an ActiveX control in C# and used it in my MFC app. The folks at MS took out support for building ActiveX controls with .NET, but it's still possible to do so with a plain Jane COM class which has a custom [ComRegisterFunction()] and [ComUnregisterFunction].

当遇到同样的问题时,我在C#中创建了一个ActiveX控件并在我的MFC应用程序中使用它。 MS的人们支持使用.NET构建ActiveX控件,但是仍然可以使用简单的Jane COM类来实现,它具有自定义[ComRegisterFunction()]和[ComUnregisterFunction]。

Although MS would like to tell us that the /clr flag will solve our problems, it measurably slowed down my large MFC app.

虽然MS想告诉我们/ clr标志将解决我们的问题,但它显着减慢了我的大型MFC应用程序。

#1


1  

A good starting point is the Win32 and WPF interop page on MSDN.

一个很好的起点是MSDN上的Win32和WPF互操作页面。

#2


1  

I found this codeproject article gave a good introduction to the subject of mixing mfc / winforms code.

我发现这个代码项目文章很好地介绍了混合mfc / winforms代码的主题。

#3


1  

When faced with the same problem, I made an ActiveX control in C# and used it in my MFC app. The folks at MS took out support for building ActiveX controls with .NET, but it's still possible to do so with a plain Jane COM class which has a custom [ComRegisterFunction()] and [ComUnregisterFunction].

当遇到同样的问题时,我在C#中创建了一个ActiveX控件并在我的MFC应用程序中使用它。 MS的人们支持使用.NET构建ActiveX控件,但是仍然可以使用简单的Jane COM类来实现,它具有自定义[ComRegisterFunction()]和[ComUnregisterFunction]。

Although MS would like to tell us that the /clr flag will solve our problems, it measurably slowed down my large MFC app.

虽然MS想告诉我们/ clr标志将解决我们的问题,但它显着减慢了我的大型MFC应用程序。