次の方法で共有


Using MFC or WinForms?

To answer a couple of questions I received as blog comments and over email, here are some brief thoughts on using MFC vs. WinForms.

In most cases today, I would recommend WinForms over MFC.  WinForms has the superior design-time experience, easier access to all of the latest platform goodies, and .NET is where the innovation is happening.

However, with that said, there are still totally lucid arguments for using MFC.  Foremost among these arguments is often the issue of performance, as your native MFC code is still very likely to provide better performance characteristics for client-side apps (particularly in the area of startup time).  The there's the whole OLE document thing -- if you're unfortunate enough to still be doing that, then MFC is probably the way to go.  MFC also has a much more rich command routing architecture, although you can write a bit of code in WinForms to solve command routing issues for most scenarios (or use a component like ComponentScience's handy CommandMaster, which handles the GUI scenarios well).  In general, MFC allows coding closer to the Win32 metal, giving you pretty convenient access to bits that can require a lot of typecasting and p/invoke busywork to get to from WinForms -- especially for GDI work.  Oh, and there's the issue of runtime; if I'm an ISV and deployment size is critical, the .NET framework runtime is still fairly large, whereas the MFC redistributables are comparatively tiny.

So, long story short, for new projects I would probably try to make WinForms work for me.  However, if I already had a large investment in MFC, I would definitely not be thinking "rewrite" but instead staying with MFC and maybe building on top of some of the new support for .NET.

Comments

  • Anonymous
    June 13, 2005
    Thats why Delphi is so good (the Win32 version that is). It gives you the design time experience of WinForms (better actually) and the performance of native code. Of course, if you want the innovation of .NET then you are back at square one.
  • Anonymous
    June 13, 2005
    Indeed, I'm a Delphi fan as well (having worked on versions 1 through 4 during my days at Borland). The quality and innovation aren't quite what they used to be, but it can still provide an extremely productive development experience for native or managed code. Delphi also provides some of the best source code compatibility between native and .NET.