Henry Sowizral on Refacing C++ with WPF in Expression Design

Download this episode

Download Video

Description

While on campus for the MVP Summit in February, I had a chance to visit Henry Sowizral over in building 41. Henry Sowizral is a Principal Architect in Microsoft Expression, and he and his team did something really cool: they converted an existing C/C++/MFC application to have a WPF front-end, while still leveraging all that existing code.

If you have legacy code and are considering porting the UI to .NET, pick up some pointers from Henry.

Once you've finished, check out Henry's presentation deck on how the team converted the Expression Design UI to WPF.

See more WPF at Pete's site and blog http://10rem.net
Follow Pete on twitter at @pete_brown

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      tomkirbygre​en

      Awesome video and very timely. I'm currently involved in trying to drag a 16 year old MFC application kicking and screaming into the WPF present and future.

    • User profile image
      freefly

      can you please post a sample showing how to change a C++ control to WPF ?

    • User profile image
      Psychlist19​72

      Any specific scenario? A MFC UI element with a bunch of existing logic, switched over to a WPF front end?

    • User profile image
      freefly

      Yes ... and moreover, best practices to follow. You can put it in the comments or a readme.txt file along the sample. Can you please talk or write about some ownerdrawn controls switching over scenario?  Thanks

    • User profile image
      Corrector2

      Was it slow as molasses after the conversion with all of the WPF bloat, sort of like Visual Studio 2010?

      Nice to see you're running Windows XP in the background, though. I found that highly amusing in a post about converting legacy code.

    • User profile image
      Psychlist19​72

      XP was in a VM if I recall correctly. He also had Windows 7 on his main machines. There's no rule against keeping machines for testing or verification. Note it was running "in the background" Smiley

       

      The slowdowns in visual studio had nothing to do with WPF. Check out the Visual Studio blog for more information. While WPF was the most visible change, a ton more was changed under the covers.

       

      Happily, with the RC, VS2010 is doing quite well now, with lots of new and useful features and perf on par with the previous version.

       

       

       

    • User profile image
      freefly

      if you are planning to post a sample and the best practice notes... could please notify me or tell me where I can expect it to show up !!!

    • User profile image
      tomkirbygre​en

      If you grep for HwndSource and in particular the "AddHook" tweak you'll get a long way with your MFC / WPF mash-ups. There are some pain points about using RenderTargetBitmap and then converting the resulting bitmap to a MFC compatible 24 bit RBG bitmap form that you can say put into a MFC ribbon - but it's all very doable. If you're not using Dev 10, i.e. you're using Visual Studio 2008 then I'd recommend doing your work in a 32 bit environment, you're going to be stepping a lot between C++, C++/CLI and C# and you will want mixed-mode debugging. I couldn't imagine doing this stuff in 64 bit before the advent of mixed-mode.

    • User profile image
      Corrector2

      If you want your business application to resemble an ATM machine, you will use WPF. If you want it to look professional (i.e., like office), you will use MFC and a good toolkit such as Codejock for ribbons and views.

    • User profile image
      Psychlist19​72

      @Connector2

       

      Trolling aside, have you see the Book of WPF? You'll see in there a number of excellent examples of WPF applications that look nothing like an Automated Teller Machine (Machine) Smiley

       

      Besides, most ATM software was C++ on OS/2 last time I looked. That was years ago, though.

       

      MFC is definitely an excellent technology. Just like WPF, though, it's not the answer to everything.

       

      Pete

    • User profile image
      Corrector2

      OK, trolling aside, I looked at the "Book of WPF." First of all, regarding said book, whoever decided to make it an 18"x9" PDF file needs to go back to design school. It was a royal pain to have to navigate it horizontally and vertically in Adobe Acrobat viewer. I did go through the entire book, though. Having done that, I basically came to the following conclusions:

       

      - For video playback apps and other "player-like" apps, exclusively, WPF with a custom GUI layout that presented the application to the user in a manner resembling a hardware player, made some amount of sense.

      - From the rest of the examples, the few implementations that looked semi-professional and not like GUI implemented by a College student on LSD, all used an Office 2007-like ribbon. These would have been better served, at least performance wise, by using MFC and Codejock's Toolkit Pro.

       

      Now, granted, I don't know how many of the apps were written in C++ and how many were written in C#. Certainly, my statements above only apply to those that were written in native C+, for which MFC was an option. Even for the C# apps, though, outside of the various players, a ribbon interface would have been much better than the hacked attempts at GUI that I saw.

       

      MS spent a small fortune on the evolution of its Windows (and Office) GUI, first using menus and toolbars and now ribbons. Most of the apps I saw spat in the face of this evolutionary development saying, "We can do reinvent the (GUI) wheel and do a better job." As software engineers, we all know the most probable outcome of someone reinventing the wheel in the software development world.

       

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.