有哪些技术迁移大型MFC应用程序中的WPF / .NET? [英] What are some techniques for migrating a large MFC application to WPF/.NET?

查看:149
本文介绍了有哪些技术迁移大型MFC应用程序中的WPF / .NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作的一个非常大的遗留MFC MDI应用程序。它有大量的用户界面元素 - 停靠栏,自定义树型控件,上下文菜单等,这是一种图像处理应用程序,以便主要观点呈现自身使用DirectX和OpenGL。该产品是10岁左右,这里的工作重点之一是更新它的外观和感觉。

I am currently working on a very large legacy MFC MDI application. It has a large number of UI elements - dockable toolbars, custom tree controls, context menus, etc. It is an image processing application so the main views render themselves using DirectX and OpenGL. The product is about 10 years old and one of the priorities here is to update the look and feel of it.

知道,微软已经做之间提供互操作性的一个好工作C ++ / MFC和.NET我认为这将是有意义的逐步迁移代码库。什么我现在正在挣扎是从哪里开始。

Knowing that Microsoft has done a good job of providing interoperability between C++/MFC and .NET I thought it would make sense to migrate the code base incrementally. What I'm struggling with now is where to start.

一种方法是撕裂了与WPF MFC框架和重用尽可能多的C ++代码的,我们可以。这将让我们最大限度的WPF架构的好处,但将意味着一个开发周期长,直到我们再次完全正常运行。

One approach is to rip out the MFC framework with WPF and reuse as much of the C++ code as we can. This will let us maximize the benefits of the WPF architecture but will mean a long development period until we're fully functional again.

另一种方法是更换MFC控制一个在与他们同行的WPF时间。这将允许我们逐步工作。我的这种方法关注的是,这意味着将有托管和非托管代码,我不知道从哪里开始替换,如主菜单和工具栏之间的事情非常多的连接点。

Another approach is to replace MFC controls one at a time with their WPF counterparts. This will allow us to work incrementally. My concern with this approach is that it means there will be an awful lot of connection points between managed and unmanaged code and I'm not sure where to start with replacing things like the main menu and toolbars.

还是有另一个选择,我没有看到?

Or is there another option here I'm not seeing?

有关此主题的任何建议或信息的链接,将不胜感激。

Any suggestions or links to information on this topic would be appreciated.

更新: DavidK提出了一些很好的问题,所以我加入这背后的动机

Update: DavidK raised some excellent questions so I'm adding the motivations behind this.

1)产品的未来发展

本产品仍在积极与定期获取添加新的功能开发。我认为这会成为一个很大的意义,试图慢慢地向C#/ WPF迁移。在我与C#/ WPF有限的经验,我发现了生产率的提高超过用C ++ / MFC工作是惊人的。

This product is still being actively developed with new features getting added on a regular basis. I thought that it would make a lot of sense to try and slowly migrate towards C#/WPF. In my limited experience with C#/WPF I found the productivity gains to be amazing over working in C++/MFC.

我们正在与WPF获得的另一件大事是采取多头系统的优势的能力。 MFC应用程序仅限于一个顶层框架,使其很难利用多台显示器。

The other big thing we're getting with WPF is the ability to take advantage of multi-head systems. MFC applications are limited to a single top level frame, making it very difficult to leverage multiple monitors.

2)员工保留和招聘

这是越来越难找到开发商谁愿意在MFC工作。这也为职业发展目前开发人员能够接触到新技术的重要。

It's getting harder and harder to find developers who are willing to work on MFC. It's also important for the career development of the current developers to get exposure to newer technologies.

推荐答案

重温这一点,因为我已经成功取代我们的顶级MFC UI(主框架,窗口和工具栏)与WPF。

Revisiting this because I have successfully replaced our top level MFC UI (the main frame, windows, and toolbars) with WPF.

事实证明,我们的核心绘图代码只需要交给一个HWND到呈现的。这使得它很容易重用大部分现有的C ++代码库

As it turns out, our core drawing code merely needs to be handed an HWND to render into. This made it really easy to reuse the bulk of our existing C++ codebase.

下面是对我采取的方法的关键件的简要介绍:

Here's a quick rundown on the key pieces of the approach I took:


  • 使用.NET的 HwndHost 举办为C的HWND ++绘图代码类呈现到

  • 创建的C ++ / CLI包装任何本地C ++代码是需要暴露在WPF / C#UI代码

  • 最左边的MFC对话框原样在本地C ++代码。这最小化以完成用户界面所需的工作量。 MFC的对话框可以随时间迁移到WPF。

  • Used the .NET HwndHost class to host an HWND for the C++ drawing code to render into
  • Created C++/CLI wrappers for any native C++ code that needed to be exposed to the WPF/C# UI code
  • Left most of the MFC dialogs as-is in the native C++ code. This minimizes the amount of work needed to finish the UI. The MFC dialogs can be migrated to WPF over time.

作为一个方面说明,我们使用SandDock和SandRibbon从的 Divelements ,并一直很满意为止。

As a side note, we're using SandDock and SandRibbon from Divelements and have been very happy with them so far.

这篇关于有哪些技术迁移大型MFC应用程序中的WPF / .NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆