16

I'm trying to call the OpenThemeData (see msdn OpenThemeData) function but I couldn't determine what are the acceptable Class names to be passed in by the pszClassList parameter.

HTHEME OpenThemeData(      
    HWND hwnd,
    LPCWSTR pszClassList
);

Could anybody tell me what are the acceptable class names that I can pass into that parameter? Thanks!

splash
  • 13,037
  • 1
  • 44
  • 67
Kiril
  • 39,672
  • 31
  • 167
  • 226

5 Answers5

14

The article Parts and States on MSDN contains a table which shows the control classes, parts, and states. The values in the table are defined in Vsstyle.h and Vssym32.h.

Here is a quick reference:

BUTTON, CLOCK, COMBOBOX, COMMUNICATIONS, CONTROLPANEL, DATEPICKER, DRAGDROP, 
EDIT, EXPLORERBAR, FLYOUT, GLOBALS, HEADER, LISTBOX, LISTVIEW, MENU, MENUBAND, 
NAVIGATION, PAGE, PROGRESS, REBAR, SCROLLBAR, SEARCHEDITBOX, SPIN, STARTPANEL, 
STATUS, TAB, TASKBAND, TASKBAR, TASKDIALOG, TEXTSTYLE, TOOLBAR, TOOLTIP, 
TRACKBAR, TRAYNOTIFY, TREEVIEW, WINDOW

The answer to the question Windows Visual Themes: Gallery of Parts and States? provides a "Parts and States Explorer" application where you can browse and test most of the styles.

Community
  • 1
  • 1
splash
  • 13,037
  • 1
  • 44
  • 67
7

I know this is an old question, but I want to give an updated answer (2018) for those who come here from Google.

The accepted answer of DavidK says to look into the file "AeroStyle.xml" where the themes are defined. This file was part of the Windows 7 SDK, but has been removed from the Windows 10 SDK, so the accepted answer is not useful anymore.

The answer of splash links to the MSDN where the list of theme names, parts and states is highly incompetlete and not updated.

The themes are drawn by UxTheme.dll which reads the images and colors, etc. from the file aero.msstyles in the folder C:\Windows\Resources\Themes\Aero on Windows 10.

To see the classes inside the XYZ.msstyles file use msstyles.Editor: https://github.com/nptr/msstyleEditor

Several themes can only be obtained if you pass the correct window handle. There seems to be an automatic mechanism which detects the type of control from a window handle. If you pass the handle of the wrong window you may get another theme handle than expected or even NULL.

Microsoft internally has changed all their code to use OpenThemeDataForDpi() instead of OpenThemeData() because each monitor on Windows 10 may have a different resolution.

The problem that we have here is a severe lack of documentation in the MSDN and a lack of an API function to enumerate all availabe themes. Shame on Microsoft (once more).

Elmue
  • 7,602
  • 3
  • 47
  • 57
6

You can look in "AeroStyle.xml" as a previous poster noted, which gives an exact list for Vista/Aero. However, if you want to play safe (and you probably do) the class names should, in general, be Windows class names of Windows common controls. For example, push buttons and check boxes use the class name "Button", the edit control "Edit", etc. I generally pick the class name of the control that's closest to whatever custom element I'm working on is, and use the theme data for that. That way you'll get code that works with XP, Vista and (hopefully) Windows 7, regardless of what the user's selected theme actually is.

However, unless you use raw Win32 a lot, you probably don't do much control creation directly using the class name. The class names are rather liberally sprinkled throughout MSDN. A good place to start is usually the "CommCtrl.h" file from the Platform SDK, which has a lot of them, and they're always described in the MSDN help on the individual common controls. You can also often learn them by looking at how dialogs are defined in .rc files by opening them in a text editor: these contain the class name for the controls.

4

Class names depend on the theme. For example, as the documentation for OpenThemeData states:

Class names for the Aero theme are defined in AeroStyle.xml, which is found in the Include folder of the Microsoft Windows Software Development Kit (SDK).

Franci Penov
  • 74,861
  • 18
  • 132
  • 169
  • 2
    You posted this in 2008. I have a Windows 10 SDK from 2015 here and this XML file does not exist. However it exists in the Windows 7 SDK. But even this XML file is incomplete. For example the class "Clock" is missing. – Elmue Nov 19 '18 at 19:42
  • Yeah, Microsoft does have an issue with updating old documentation to the latest OS/platform releases. :-) Unfortunately, I haven't looked at Windows since 2011, so can't really help much with updating this answer. – Franci Penov Nov 20 '18 at 18:05
0

It has nothing to do with Aero, which even doesn't exits on XP ! See the source code of OpenThemeData()..

  • Aero was given as an example where to look for more info on the various class names supported by themes. You should not imply connection where none was specified. – Franci Penov Oct 20 '08 at 17:55
  • I suppose you wanted to post this as a comment to the answer of DavidK rather than an own answer, because this is not an answer to the question. – Elmue Nov 21 '18 at 15:33