What are some techniques for migrating a large MFC application to WPF/.NET?

后端 未结 5 1365
醉话见心
醉话见心 2020-12-24 02:07

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 i

5条回答
  •  误落风尘
    2020-12-24 02:26

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

    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:

    • 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.

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

提交回复
热议问题