How to get Windows XP look in MFC application

| | Comments (1)
Sometimes I don't understand what they do over there in Redmond. No, I'm not one of those that hate microsoft, quite the opposite. But still, they continue to do surprise me from time to time. Consider this sample MFC application: Standard MFC application This is what I get from the MFC app wizard in Visual Studio .Net 2005. I have created a Doc/View app and selected CFormView as my initial view and I've added a few sample controls to the view. Is this what you expect from your $10.000+ IDE in 2006? I guess not, read on. Let's see what we need to do to our MFC application in order to spice it up. The problem here is that in order to get that nice XP look you'll have to use the common controls dll version 6. If you look in your stdafx.h file you should have the following lines when using .Net 2005: [cpp] // Allow use of features specific to IE 6.0 or later. // Change this to the appropriate value to target other versions of IE. #ifndef _WIN32_IE #define _WIN32_IE 0x0600 #endif [/cpp] This might fool you to think it allows you to use features specific to IE 6.0 or later. But the seasoned programmer that Microsoft targets knows this isn't enough. In Windows XP or later you need a manifest to tell what version of common controls dll to use. This is a simple 3-step process for an MFC application. 1. First we add this line to resource.h [cpp] #define IDR_MANIFEST 1 [/cpp] 2. Then add the following to your .rc2 file (MyApp.rc2) [cpp] IDR_MANIFEST RT_MANIFEST MOVEABLE PURE "res\\MyApp.manifest" [/cpp] 3. The last step is to add the actual manifest file. Create a new textfile in your favorite text editor paste the following. Don't forget to change MyApp to your applications name. Then save it as "MyApp.manifest" in your projects "res" folder. [xml] MyApp [/xml] Rebuild your application and find your MFC application has suddenly changed skin: Modern MFC application This wasn't very hard, right? Why didn't Microsoft add this to appwiz generated applications? Maybe they would argue that they don't know what version of common controls dll you are targeting, but a simple check that _WIN32_IE is 0x600 would solve that. I really don't know what they are doing over there in Redmond, but I'd expect they atleast document this functionality. Sigh.

1 Comments

Well, M$ is currently being sued for millions of Euro for poor documentation, so you should have seen it coming ;)

I've managed to carefully avoid relying on Microsoft for programming. Apart from DirectX 7 back in 2000, the last thing I used was MASM 6.0 in the old DOS days.

Leave a comment

About this Entry

This page contains a single entry by Andreas Thorsén published on July 16, 2006 8:22 PM.

Easy screenshots was the previous entry in this blog.

The important Post-Build Event is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.