Click here to Skip to main content
13,251,998 members (58,924 online)
Click here to Skip to main content
Add your own
alternative version


93 bookmarked
Posted 14 Sep 2003

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

You may also be interested in...


Comments and Discussions

QuestionManifest file Pin
Deepa_R11-Dec-15 19:06
memberDeepa_R11-Dec-15 19:06 
QuestionArrow sign for Tree Control instead of plus/minus sign Pin
Member 789460112-Jun-14 19:47
memberMember 789460112-Jun-14 19:47 
QuestionMust use a manifest File Pin
sayer19-Dec-12 15:48
membersayer19-Dec-12 15:48 
QuestionXP Style for Custom contro Pin
eprakash198723-Aug-12 2:25
membereprakash198723-Aug-12 2:25 
GeneralThanks! Pin
Alan Balkany16-Jul-10 17:02
memberAlan Balkany16-Jul-10 17:02 
GeneralWindows 7? [modified] Pin
billyjoesunday22-Jan-10 11:32
memberbillyjoesunday22-Jan-10 11:32 
GeneralAnother Way Pin
heiitx7-Dec-09 1:24
memberheiitx7-Dec-09 1:24 
GeneralRe: Another Way Pin
metalinspired17-Dec-09 11:53
membermetalinspired17-Dec-09 11:53 
QuestionManifest dependency reduces performance? Pin
mala P30-Sep-08 12:28
membermala P30-Sep-08 12:28 
QuestionIs it possible to enable xp theme in win32 application without manifest..? Pin
basawaraj17-May-08 2:09
memberbasawaraj17-May-08 2:09 
Dear All,

In our application I tried with compiler directive

#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

It works fine VS 2005 and later versions,

I need the solution for enabling the xp themes in application without manifest file in all Visual Stdio versions(Including VS 2003, 2004).

Please help me,

Eagerly waiting for reply

Basavaraj Bijjaragi
GeneralEnable (or Embed ) XP theme in win32 application Pin
basawaraj15-May-08 21:51
memberbasawaraj15-May-08 21:51 
GeneralRe: Enable (or Embed ) XP theme in win32 application Pin
vijay shankar12-Jun-08 2:25
membervijay shankar12-Jun-08 2:25 
Generalvc4.0 Pin
Riick12-May-08 6:01
memberRiick12-May-08 6:01 
GeneralSomething isn't right here Pin
alan9326-Aug-07 12:05
memberalan9326-Aug-07 12:05 
GeneralRe: Something isn't right here Pin
Priya_Sundar17-Mar-08 20:40
memberPriya_Sundar17-Mar-08 20:40 
GeneralDoes not work for a simple Win32 APP Pin
samwise_i16-Mar-07 13:30
membersamwise_i16-Mar-07 13:30 
GeneralRe: Does not work for a simple Win32 APP Pin
anvil_of_crom19-Nov-07 0:27
memberanvil_of_crom19-Nov-07 0:27 
Questionhow do you rollback ? Pin
sperate132-Feb-07 3:50
membersperate132-Feb-07 3:50 
AnswerRe: how do you rollback ? Pin
sperate132-Feb-07 5:15
membersperate132-Feb-07 5:15 
QuestionIs This Needed? Pin
alan9327-Jul-06 4:43
memberalan9327-Jul-06 4:43 
AnswerRe: Is This Needed? Pin
fiuygloINS18-Aug-07 7:42
memberfiuygloINS18-Aug-07 7:42 
Generalworks like a charm Pin
vjedlicka18-Jul-06 6:01
membervjedlicka18-Jul-06 6:01 
GeneralUsing Windows XP Styles in WIN32 Applications Pin
prem kumar singh20-Dec-06 20:51
memberprem kumar singh20-Dec-06 20:51 
GeneralVisual Studio 2005 linking errors. Pin
Xanblax14-Dec-05 14:29
memberXanblax14-Dec-05 14:29 
GeneralRe: Visual Studio 2005 linking errors. Pin
Xanblax14-Dec-05 14:36
memberXanblax14-Dec-05 14:36 
AnswerRe: Visual Studio 2005 linking errors. Pin
Kluch15-Dec-05 19:28
memberKluch15-Dec-05 19:28 
GeneralRe: Visual Studio 2005 linking errors. Pin
Xanblax16-Dec-05 9:35
memberXanblax16-Dec-05 9:35 
GeneralRe: Visual Studio 2005 linking errors. Pin
4jb4-Jul-09 9:56
member4jb4-Jul-09 9:56 
GeneralRe: Visual Studio 2005 linking errors. [modified] Pin
sciencekrishnan20-Jul-09 23:31
membersciencekrishnan20-Jul-09 23:31 
GeneralRe: Visual Studio 2005 linking errors. Pin
sciencekrishnan22-Jul-09 2:06
membersciencekrishnan22-Jul-09 2:06 
GeneralRe: Visual Studio 2005 linking errors. Pin
NoName235-Apr-07 6:03
memberNoName235-Apr-07 6:03 
GeneralExtending this to applications running in Win 2000 Pin
Andyzyx16-Jul-05 13:21
memberAndyzyx16-Jul-05 13:21 
GeneralRe: Extending this to applications running in Win 2000 Pin
Anna-Jayne Metcalfe6-Oct-05 8:07
memberAnna-Jayne Metcalfe6-Oct-05 8:07 
GeneralMSFlexGrid Control not themed Pin
Joe Colosi8-Jun-05 5:18
memberJoe Colosi8-Jun-05 5:18 
Generalneed help please Pin
KingKonni22-Feb-05 21:57
memberKingKonni22-Feb-05 21:57 
GeneralWorks great Pin
richard sancenot3-Aug-04 23:23
memberrichard sancenot3-Aug-04 23:23 
GeneralTrouble with CToolbar Pin
manero30-Jan-04 3:57
membermanero30-Jan-04 3:57 
GeneralRe: Trouble with CToolbar Pin
What's my name?5-Feb-06 14:23
memberWhat's my name?5-Feb-06 14:23 
QuestionRe: Trouble with CToolbar Pin
flyingxu8-Nov-06 16:29
memberflyingxu8-Nov-06 16:29 
GeneralRe: Trouble with CToolbar Pin
kj_kho30-Jul-08 20:23
memberkj_kho30-Jul-08 20:23 
QuestionHow to enable XP style in MFC dll Pin
salonent8-Oct-03 20:39
membersalonent8-Oct-03 20:39 
AnswerRe: How to enable XP style in MFC dll Pin
Dick Marjot23-Dec-04 20:49
memberDick Marjot23-Dec-04 20:49 
AnswerRe: How to enable XP style in MFC dll Pin
Shail_Srivastav15-Feb-05 2:21
memberShail_Srivastav15-Feb-05 2:21 
AnswerRe: How to enable XP style in MFC dll Pin
Anonymous4-May-05 14:10
sussAnonymous4-May-05 14:10 
GeneralRe: How to enable XP style in MFC dll Pin
marijan_s3-Aug-07 11:43
membermarijan_s3-Aug-07 11:43 
GeneralWin 2000 Pin
olis23-Sep-03 4:14
memberolis23-Sep-03 4:14 
GeneralRe: Win 2000 Pin
Kluch24-Sep-03 17:55
memberKluch24-Sep-03 17:55 
Generalpassword character Pin
Anonymous17-Sep-03 10:16
sussAnonymous17-Sep-03 10:16 
GeneralRe: password character Pin
Kluch20-Sep-03 11:38
memberKluch20-Sep-03 11:38 
GeneralRe: password character Pin
jutapy22-Sep-03 21:56
sussjutapy22-Sep-03 21:56 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 15 Sep 2003
Article Copyright 2003 by MKlucher
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid