Nip & Tuck for GUIs (a.k.a. the scoop on Expression Design’s past)


So you may know that AutoCAD 2009 uses WPF for it's "chrome" (no not that Chrome, the other chrome i.e. ribbon, action recorder and QuickView).

image

What's probably less well known (but which you can learn about at the MIX 08 University in this session) is that Expression Design, below, has quite a lot in common with AutoCAD 2009.

 

image

For context, Expression Design is one of the Expression Suite of Products. Some of them, such as Expression Blend are shiny new applications written in WPF and C#. Expression Design, however has a past 🙂 And that past is that Expression Design is based on a 10 year-old MFC C++ code base.

You can tell as much by using the excellent Snoop utility for WPF. 

image

Actually the above was just the gratuitous 3D shot from Snoop, just because it's cool. The below screenshot though highlights an element whose type is a subclass of HwndHost....

image

This is typically done so that MFC code can access the WPF Hwnd that parents the MFC "island", in this case the design surface.

(credits: the screenshots below are taken from the PPT deck presented at the MIX session, presented by Henry Sowizral)

Essentially what was done was to pry apart the old UI from the core functionality of the application i.e. the design surface in this case,

 

image

 

then new chrome was bolted on via an interop layerto connect the WPF UI with the MFC Code.

 

image

 

And the result is an app that has a WPF look and feel - can you tell the difference between the 100% managed code app (Blend) and the WPF / MFC combo (Design)?

 

image

image

 

My guess is no, because they have a consistent look and feel which you associate with the Expression Suite of products, yet it was achieved without throwing out the previous investments in a design tool - not even Microsoft has unlimited resources!

So what's my point? Well, you may not have MFC code, instead you may have VB6 code or perhaps Windows Forms and perhaps you're thinking that WPF isn't an option for you unless you're starting off a new project, from scratch.

Well, think again...If you've got Windows Forms code you can add in some WPF as you go using either ElementHost (a Windows Forms control that can be used to host a WPF element) or WindowsFormsHost (host a Windows Forms control on a WPF page).

If you've got VB6 code you can use the Forms Interop Toolkit to incorporate Windows Forms into your applications as an alternative to "big-bang" migration, perhaps as part of a phased migration, so that you can move your VB6 investments to .NET and use its "bigger lego" 🙂

(I've also successfully used the Forms Interop Toolkit to host an ElementHost which in turn hosted a WPF user control (hope to blog about this shortly))

Ultimately, if you compare UIs these days to the traditional "battleship grey" applications it's clear things have moved on - Office 2007 being a case in point.The availability of 3rd party ribbon controls and Microsoft's own preview version makes it possible to incorporate this functionality into some of your existing applications via interop, allowing you to nip & tuck your UI without a huge investment or a rewrite.

I'm hoping to go through some of scenarios in followup posts, specifically how to replace a menu in a Win Forms app with a WPF ribbon control. If you're in Ireland/Northern Ireland and would like to discuss your options here in more detail please feel free to contact me, and / or send your feedback on the above.

Comments (4)

  1. I figure the most logical follow-on from my last post is to show how simple it is to start using WPF

  2. I figure the most logical follow-on from my last post is to show how simple it is to start using WPF

  3. Thanks to everyone who attended our User Experience day here in Sandyford last week.  Guest speaker

Skip to main content