Click here to Skip to main content
11,409,854 members (61,145 online)
Click here to Skip to main content

Using Windows XP Styles in your MFC/WIN32 Applications

, 14 Sep 2003
Rate this:
Please Sign up or sign in to vote.
A simple and short guide to adding and using XP styles in your MFC/Win32 application.


I wanted to try and write an article for the The Code Project and thought this would be a good start. It's a little short but hopefully a few people will find it useful. If you have any suggestions on the article let me know.

So what's it about?

This article will show you how to quickly and easily add the capability to use themes under XP. This means whatever theme the user is using under Windows XP will control the look of your application. See the example below:

Sample image

Windows 95, 98, ME, 2000

Sample image

Windows XP

Manifest yourself

One of the first things that need to be done to use XP Styles in your MFC application is to create the manifest XML file for your application. You can paste the following code into a new notepad document and save it in a file called manifest.xml. Save this file in your project directory. It's not required, but you can fill in the description and name of your application if you would like.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
 <description>Your application description here.</description> 

Once that is completed, you will want to add the manifest.xml file to your project in the resource editor. In Visual Studio 6, hit Ctrl+R to add a new resource, select all files and double click manifest.xml to add the file. When you see the custom resource dialog, enter the number "24" as the resource type and hit OK. Once imported, right click on the resource to open the properties window and change the ID to the number "1".

Just one line...

To initialize everything you need to call InitCommonControls() in your program. I usually put this in the InitInstance() function but you can also use in the InitDialog() and still have it work. It should look something like this:

//Make sure this is here so you can use XP Styles

Now when you run your program you should see XP style controls in your program, unless of course you have Windows XP set to the classic style which then everything will pretty much look the same.

I want more info!

If you're looking for some more information on using XP themes in your code I would recommend checking one of the best resources I have found for information on MSDN. The page is here.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Program Manager Microsoft
United States United States
No Biography provided

Comments and Discussions

QuestionArrow sign for Tree Control instead of plus/minus sign PinmemberMember 789460112-Jun-14 19:47 
QuestionMust use a manifest File Pinmembersayer19-Dec-12 15:48 
QuestionXP Style for Custom contro Pinmembereprakash198723-Aug-12 2:25 
GeneralThanks! PinmemberAlan Balkany16-Jul-10 17:02 
GeneralWindows 7? [modified] Pinmemberbillyjoesunday22-Jan-10 11:32 
Has anyone tried this on Windows 7? I have a couple of controls that don't work right when I add the manifest file. Everything works fine on XP but not Windows 7.

Update... The common controls ver 6 on Windows 7 can cause problems if you render the graphics yourself, via the Draw() method. We had a ListCtrl where we rendered the gridlines based on a hardcoded font size and ended up with lines in the middle of our text. Also, our context menu calculation were wrong due to the listctrl header and font being a slightly different size. The fix is to dynamically calculate all offsets and font size based on the control and actual font being used. I am sure no one else is supporting an old product with hard coded values in thier rendering Smile | :)

This article was also very helpful:
Changing Row Height in an owner drawn Control[^]

modified on Thursday, January 28, 2010 4:31 PM

GeneralAnother Way Pinmemberheiitx7-Dec-09 1:24 
GeneralRe: Another Way Pinmembermetalinspired17-Dec-09 11:53 
QuestionManifest dependency reduces performance? Pinmembermala P30-Sep-08 12:28 
QuestionIs it possible to enable xp theme in win32 application without manifest..? Pinmemberbasawaraj17-May-08 2:09 
GeneralEnable (or Embed ) XP theme in win32 application Pinmemberbasawaraj15-May-08 21:51 
GeneralRe: Enable (or Embed ) XP theme in win32 application Pinmembervijay shankar12-Jun-08 2:25 
Generalvc4.0 PinmemberRiick12-May-08 6:01 
GeneralSomething isn't right here Pinmemberalan9326-Aug-07 12:05 
GeneralRe: Something isn't right here PinmemberPriya_Sundar17-Mar-08 20:40 
GeneralDoes not work for a simple Win32 APP Pinmembersamwise_i16-Mar-07 13:30 
GeneralRe: Does not work for a simple Win32 APP Pinmemberanvil_of_crom19-Nov-07 0:27 
Questionhow do you rollback ? Pinmembersperate132-Feb-07 3:50 
AnswerRe: how do you rollback ? Pinmembersperate132-Feb-07 5:15 
QuestionIs This Needed? Pinmemberalan9327-Jul-06 4:43 
AnswerRe: Is This Needed? PinmemberfiuygloINS18-Aug-07 7:42 
Generalworks like a charm Pinmembervjedlicka18-Jul-06 6:01 
GeneralUsing Windows XP Styles in WIN32 Applications Pinmemberprem kumar singh20-Dec-06 20:51 
GeneralVisual Studio 2005 linking errors. PinmemberXanblax14-Dec-05 14:29 
GeneralRe: Visual Studio 2005 linking errors. PinmemberXanblax14-Dec-05 14:36 
AnswerRe: Visual Studio 2005 linking errors. PinmemberKluch15-Dec-05 19:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150414.5 | Last Updated 15 Sep 2003
Article Copyright 2003 by MKlucher
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid