<p>My company has developed a long standing product using MFC in Visual C++ as the defacto standard for UI development. Our codebase contains ALOT of legacy/archaic code which must be kept operational. Some of this code is older than me (originally written in the late 70s) and some members of our team are still on Visual Studio 6.</p>

<p>However, a conclusion has thankfully been reached internally that our product is looking somewhat antiquated compared to our competitors', and that something needs to be done.</p>

<p>I am currently working on a new area of the UI which is quite separate from the rest of the product. I have therefore been given the chance to try out 'new' technology stacks as a sort of proving ground before the long process of moving over the rest of the UI begins.</p>

<p>I have been using C# with Windows Forms and the .net framework for a while in my spare time and enjoy it, but am somewhat worried about the headaches caused by interop. While this particular branch of the UI won't require much interop with the legacy C++ codebase, I can forsee this becoming an issue in the future.</p>

<p>The alternative is just to continue with MFC, but try and take advantage of the new feature pack that shipped with VS2008. This I guess is the easiest option, but I worry about longevity and not taking advantage of the goodness that is .net...</p>

<p>So, which do I pick? We're a small team so my recommendation will quite probably be accepted as a future direction for our development - I want to get it right.</p>

<p>Is MFC dead? Is C#/Winforms the way forward? Is there anything else I'm totally missing? Help greatly appreciated!</p>

[{'answer_id': 10904, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 1, 'selected': False, 'text': "<p>Were you to look at moving to C# and therefore .NET, I would consider Windows Presentation Foundation rather than WinForms. WPF is the future of smart clients in .NET, and the skills you pick up you'll be able to reuse if you want to make browser-hosted Silverlight applications.</p>\n"}, {'answer_id': 10909, 'author': 'JamesSugrue', 'author_id': 1075, 'author_profile': 'https://Stackoverflow.com/users/1075', 'pm_score': 0, 'selected': False, 'text': "<p>I concur with the WPF sentiment. Tag/XML based UI would seem to be a bit more portable than WinForms.</p>\n\n<p>I guess too you have to consider your team, if there is not a lot of current C# skills, then that is a factor, but going forward the market for MFC developers is diminishing and C# is growing.</p>\n\n<p>Maybe some kind of piecemeal approach would be possible? I have been involved with recoding legacy applications to C# quite a bit, and it always takes a lot longer than you would estimate, especially if you are keeping some legacy code, or your team isn't that conversant with C#.</p>\n"}, {'answer_id': 10911, 'author': 'Zooba', 'author_id': 891, 'author_profile': 'https://Stackoverflow.com/users/891', 'pm_score': 2, 'selected': False, 'text': "<p>Depending on the application and the willingness of your customers to install .NET (not all of them are), I would definitely move to WinForms or WPF. Interop with C++ code is hugely simplified by refactoring non-UI code into class libraries using C++/CLI (as you've noted in your selection of tags).</p>\n\n<p>The only issue with WPF is that it may be hard to maintain the current look-and-feel. Moving to WinForms can be done while maintaining the current look of your GUI. WPF uses such a different model that to attempt to keep the current layout would probably be futile and would definitely not be in the spirit of WPF. WPF also apparently has poor performance on pre-Vista machines when more than one WPF process is running.</p>\n\n<p>My suggestion is to find out what your clients are using. If most have moved to Vista and your team is prepared to put in a lot of GUI work, I would say skip WinForms and move to WPF. Otherwise, definitely look seriously at WinForms. In either case, a class library in C++/CLI is the answer to your interop concerns.</p>\n"}, {'answer_id': 10918, 'author': 'Brian Lyttle', 'author_id': 636, 'author_profile': 'https://Stackoverflow.com/users/636', 'pm_score': 2, 'selected': False, 'text': '<p>You don\'t give a lot of detail on what your legacy code does or how it\'s structured. If you have certain performance criteria you might want to maintain some of your codebase in C++. You\'ll have an easier time doing interop with your old code if it is exposed in the right way - can you call into the existing codebase from C# today? Might be worth thinking about a project to get this structure right.</p>\n\n<p>On the point of WPF, you could argue that WinForms may be more appropriate. Moving to WinForms is a big step for you and your team. Perhaps they may be more comfortable with the move to WinForms? It\'s better documented, more experience in the market, and useful if you still need to support windows 2000 clients.</p>\n\n<p>You might be interested in <a href="https://rads.stackoverflow.com/amzn/click/com/032117352X" rel="nofollow noreferrer" rel="nofollow noreferrer">Extending MFC Applications with the .NET Framework</a></p>\n\n<p>Something else to consider is <a href="http://en.wikipedia.org/wiki/C%2B%2B/CLI" rel="nofollow noreferrer">C++/CLI</a>, but I don\'t have experience with it.</p>\n'}, {'answer_id': 11002, 'author': 'Ali Parr', 'author_id': 1169, 'author_profile': 'https://Stackoverflow.com/users/1169', 'pm_score': 2, 'selected': False, 'text': "<p>Thank you all kindly for your responses, it's reassuring to see that generally the consensus follows my line of thinking. I am in the fortunate situation that our software also runs on our own custom hardware (for the broadcast industry) - so the choice of OS is really ours and is thrust upon our customers. Currently we're running XP/2000, but I can see a desire to move up to Vista soon.</p>\n\n<p>However, we also need to maintain very fine control over GPU performance, which I guess automatically rules out WPF and hardware acceleration? I should have made that point in my original post - sorry. Perhaps it's possible to use two GPUs... but that's another question altogether...</p>\n\n<p>The team doesn't have any significant C# experience and I'm no expert myself, but I think the overall long term benefits of a managed environment probably outweigh the time it'll take to get up to speed.</p>\n\n<p>Looks like Winforms and C# have it for now.</p>\n"}, {'answer_id': 11004, 'author': 'Aidan Ryan', 'author_id': 1042, 'author_profile': 'https://Stackoverflow.com/users/1042', 'pm_score': 4, 'selected': True, 'text': '<p>I\'m a developer on an app that has a ton of legacy MFC code, and we have all of your same concerns. A big driver for our strategy was to eliminate as much risk and uncertainty as we could, which meant avoiding The Big Rewrite. As we all know, TBR fails most of the time. So we chose an incremental approach that allows us to preserve modules that won\'t be changing in the current release, writing new features managed, andporting features that are getting enhancements to managed.</p>\n\n<p>You can do this several ways:</p>\n\n<ol>\n<li><p>Host WPF content on your MFC views (see <a href="http://www.codeguru.com/cpp/cpp/cpp_managed/interop/article.php/c14589" rel="nofollow noreferrer">here</a>)</p></li>\n<li><p>For MFC MDI apps, create a new WinForms framework and host your MFC MDI views (see <a href="http://www.codeproject.com/KB/miscctrl/HostMFC.aspx" rel="nofollow noreferrer">here</a>)</p></li>\n<li><p>Host WinForms user controls in MFC Dialogs and Views (see <a href="http://msdn.microsoft.com/en-us/library/ahdd1h97.aspx" rel="nofollow noreferrer">here</a>)</p></li>\n</ol>\n\n<p>The problem with adopting WPF (option 1) is that it will require you to rewrite all of your UI at once, otherwise it\'ll look pretty schizophrenic.</p>\n\n<p>The second approach looks viable but very complicated.</p>\n\n<p>The third approach is the one we selected and it\'s been working very well.  It allows you to selectively refresh areas of your app while maintaining overall consistency and not touching things that aren\'t broken.</p>\n\n<p>The Visual C++ 2008 Feature Pack looks interesting, I haven\'t played with it though. Seems like it might help with your issue of outdated look. If the "ribbon" would be too jarring for your users you could look at third-party MFC and/or WinForms control vendors.</p>\n\n<p>My overall recommendation is that interop + incremental change is definitely preferable to sweeping changes.</p>\n\n<hr>\n\n<p>After reading your follow-up, I can definitely confirm that the productivity gains of the framework vastly outweigh the investment in learning it. Nobody on our team had used C# at the start of this effort and now we all prefer it.</p>\n'}]
['https://Stackoverflow.com/questions/10901', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1169/']