Click here to Skip to main content
15,393,706 members
Articles / Programming Languages / C++
Posted 1 Jun 2005


28 bookmarked

How to accurately detect if an application is theme-enabled?

Rate me:
Please Sign up or sign in to vote.
4.58/5 (19 votes)
1 Jun 20051 min read
Describes a function that overcomes the inadequacies of IsAppThemed and IsThemeActive.

Image 1

Fig. 1 : System wide and app-specific themes enabled

Image 2

Fig. 2 : System wide themes enabled, app-specific themes disabled

Image 3

Fig. 3 : System wide themes disabled. (App-specific doesn't matter)


When you develop custom controls that work differently depending on whether the application has themes enabled or not, you need to detect whether the currently running application is using themes or not. MSDN lists two functions IsAppThemed and IsThemeActive and I list below snippets from their documentation :-

IsAppThemed Function - Reports whether the current application's user interface displays using visual styles.
IsThemeActive Function - Tests if a visual style for the current application is active.

You'd think that all you need to do is to use one or both of these functions, wouldn't you? Guess what? On XP (even SP2) both these functions return

if your system wide themes setting is enabled. Thus any system that's using an XP styled theme will always have these two functions returning TRUE.

I googled around and didn't find anything worthwhile. I saw a posting from Jeff Partch (MVP) who suggested calling GetModuleHandle on comctl32.dll and comparing this module handle with the handle returned by calling GetClassLongPtr on a known control handle with the

flag. While I didn't actually try that out, I thought it'd be easier to call DllGetVersion on comctl32.dll and check if the version is 6 or greater.

The IsThemed function

The code lavishly uses LoadLibrary/GetProcAddress to avoid a dependency on the PSDK (the code now compiles on the default installation of VC++ 6).

#pragma once

#include "stdafx.h"
#include <Shlwapi.h>

BOOL IsThemed()
    BOOL ret = FALSE;
    OSVERSIONINFO ovi = {0};
    ovi.dwOSVersionInfoSize = sizeof ovi;
    if(ovi.dwMajorVersion==5 && ovi.dwMinorVersion==1)
        //Windows XP detected
        typedef BOOL WINAPI ISAPPTHEMED();
        HMODULE hMod = LoadLibrary(_T("uxtheme.dll"));
            pISAPPTHEMED = reinterpret_cast<ISAPPTHEMED*>(
            pISTHEMEACTIVE = reinterpret_cast<ISTHEMEACTIVE*>(
                if(pISAPPTHEMED() && pISTHEMEACTIVE())                

                    HMODULE hModComCtl = LoadLibrary(_T("comctl32.dll"));
                        pDLLGETVERSION = reinterpret_cast<DLLGETVERSION*>(
                            DLLVERSIONINFO dvi = {0};
                            dvi.cbSize = sizeof dvi;
                            if(pDLLGETVERSION(&dvi) == NOERROR )
                                ret = dvi.dwMajorVersion >= 6;
    return ret;

Using the code

    m_bThemed = true;
    m_bThemed = false;


  • June 02, 2005 - Article first published


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

Nish Nishant
United States United States
Nish Nishant is a Principal Software Architect based out of Columbus, Ohio. He has over 17 years of software industry experience in various roles including Lead Software Architect, Principal Software Engineer, and Product Manager. Nish was a Microsoft Visual C++ MVP between 2002 and 2015.

Nish is an industry acknowledged expert in the Microsoft technology stack. He authored C++/CLI in Action for Manning Publications in 2005, and had previously co-authored Extending MFC Applications with the .NET Framework for Addison Wesley in 2003. In addition, he has over 140 published technology articles on and another 250+ blog articles on his WordPress blog. Nish is vastly experienced in team management, mentoring teams, and directing all stages of software development.

Contact Nish : If you are interested in hiring Nish as a consultant, you can reach him via his google email id voidnish.

Company Website :

Comments and Discussions

QuestionIs there a reason to check IsAppThemed / IsThemeActive first? Pin
peterchen24-Mar-09 7:11
Memberpeterchen24-Mar-09 7:11 
GeneralSuggestion: No need to check comctl32.dll version Pin
Sumit Kapoor2-Aug-06 20:38
MemberSumit Kapoor2-Aug-06 20:38 
GeneralRe: Suggestion: No need to check comctl32.dll version Pin
Anil K P10-Jun-07 23:54
MemberAnil K P10-Jun-07 23:54 
GeneralRe: Suggestion: No need to check comctl32.dll version Pin
Keith Worden17-Jul-08 2:40
MemberKeith Worden17-Jul-08 2:40 
GeneralUnicode Pin
Warren Stevens13-Nov-05 2:34
MemberWarren Stevens13-Nov-05 2:34 
GeneralRe: Unicode Pin
Nish Nishant13-Nov-05 2:38
sitebuilderNish Nishant13-Nov-05 2:38 
GeneralMaking code Vista (or later) friendly Pin
Warren Stevens11-Nov-05 7:21
MemberWarren Stevens11-Nov-05 7:21 
GeneralRe: Making code Vista (or later) friendly Pin
Yongchun8-Jan-06 0:28
MemberYongchun8-Jan-06 0:28 
GeneralRe: Making code Vista (or later) friendly Pin
Warren Stevens11-Jan-06 5:21
MemberWarren Stevens11-Jan-06 5:21 
GeneralRe: Making code Vista (or later) friendly Pin
Keith Worden17-Jul-08 2:37
MemberKeith Worden17-Jul-08 2:37 
GeneralRe: Making code Vista (or later) friendly Pin
Warren Stevens17-Jul-08 17:21
MemberWarren Stevens17-Jul-08 17:21 
GeneralRe: Making code Vista (or later) friendly Pin
Keith Worden18-Jul-08 0:11
MemberKeith Worden18-Jul-08 0:11 
GeneralIsAppThemed returns FALSE for a Windows XP (Modified) theme Pin
Brian KS6-Oct-05 6:52
sussBrian KS6-Oct-05 6:52 
Questionxp+ ? Pin
Huisheng Chen2-Jun-05 2:51
MemberHuisheng Chen2-Jun-05 2:51 
AnswerRe: xp+ ? Pin
Nish Nishant2-Jun-05 5:42
sitebuilderNish Nishant2-Jun-05 5:42 

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.