Improving MFC for Windows Vista - First Impressions
(Page 2 of 4 )
For a start let’s examine how a simple project made by Visual Studio 2005 looked. We will ignore any improvements offered by Vista itself as we are only interested in what changes are brought by Visual Studio 2008 itself, not what additions will automatically be implemented by the Vista OS. To test this I used Vista Ultimate Edition with some custom styling based on the Aero Interface.

-> Basic with VS2005 under Vista <-

-> Basic with VS2008 under Vista <-
Remember that all we did was recompile the source code after Studio converted the solution from version 8 to 9. The first and only obvious change added to it is the toolbar, which takes the Systems style with the version 9 compiler.
Also, the new version offers the option of using higher-quality icons, giving a 48X48 resolution and two versions, 8 bits or 24 bits. This way the icons will look nicer on those high resolution computers we all tend to have these days.
Basically this is all you can squeeze from this part with just a recompile. It's not much, however I’m sure you observed that IE 7 and the new Media Player from Microsoft don't have the menu bar on by default. It just pops up once you push the ALT key.
This little trick can be implemented easily with one line of code in any SDI application. The reason these work for SDI only is that the Visual C++ developing team found that it was unclear what should happen with a MDI application with the child Windows close/minimize/maximize button as Sarita Banta expressed in a forum post over the MSDN forum.
Additionally “most of the MDI apps have complex menus and Vista UX guidelines do not encourage hiding complex menu bars.” So this function has been overwritten in the MDI-based application, so if you pass any argument other than "keep always on" you’ll get an assertion failure.
The argument I’m talking about is AFX_MBV_KEEPVISIBLE, which tells the compiler to maintain the old-style menu and will be applied by default. The argument can also be set to AFX_MBV_DISPLAYONFOCUS (for ALT toggle of the menu bar) andAFX_MBV_DISPLAYONF10 (for an F10 key toggle). Of course these can be combined by applying a bitwise or operation.
All you have to do is call the:
virtual void SetMenuBarVisibility( DWORD nStyle );
Like this for an ALT toggle:
SetMenuBarVisibility(AFX_MBV_DISPLAYONFOCUS);
To go from a window like this compiled under VS 8.0:

To a more stylish:

Or even a less busy version if we deactivate the toolbar also… see below.

One more tip: you may want to make sure to use the Clear Type technology implemented in Vista. This allows you to use anti-aliasing on the fonts for a more stylish feeling to them, and also to make sure that some texts (mainly in Dialogs) don’t look slightly off.
To do so you only need to use a font that supports anti-aliasing. Just about any free types that use bitmap images can be applied to it, but to make sure they are a little more synchronized with the system, choose the Use System font in the dialogs Properties window.:

This will lead to getting the current system that is saved under the registry key in the:HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsNTCurrentVersion FontSubstitutes path. With a Vista with English installation this will be Microsoft Sans Serif.
Next: The Open/Save Dialog >>
More Windows Scripting Articles
More By Gabor Bernat