32

Microsoft Windows lets programmers draw GUI elements using the look and feel of the current theme using functions like DrawThemeBackground and DrawThemeText. The elements are specified by Class, Part, and State, as described at the Parts and States page at MSDN.

Unfortunately, the page is not very informative (at all!). So the question is: is there somewhere a reference of all these parts and states, preferably with images of the elements (in the default Windows Vista/7 theme)?

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384

4 Answers4

48

I have created a small Windows application, programmed with the table at Parts and States. This application lets the programmer browse and explore all parts and states, using the current OS theme.

Parts and States Explorer
(High-Res)

It can be downloaded at

The (Delphi, Win32 API) source, which is too long to be posted here (due to hundreds of constants) is found at

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
  • @TOndrej: Now the *.zip file contains everything you need to compile it right away (I hope). – Andreas Rejbrand Oct 24 '10 at 20:04
  • 1
    Wonderful! Thank you very much! Compiles fine now, needs only a few small changes for D2007. – Ondrej Kelle Oct 24 '10 at 20:22
  • Windows Vista added new classes and parts (the Wizard is one that comes to mind). So your app would need to be updated with the new constants. Privately i've continued to update Mike Lichske's Theme Explorer, and ThemeSrv, in Delphi 5. – Ian Boyd Nov 30 '10 at 18:20
  • @Ian Boyd: That message wasn't meant for me, right? My app includes even the Windows 7 additions. – Andreas Rejbrand Nov 30 '10 at 18:43
  • @Andreas Rejbrand. i don't see it; is it in the built exe? – Ian Boyd Dec 02 '10 at 03:07
  • @Ian: Every single part and state at http://msdn.microsoft.com/en-us/library/bb773210(VS.85).aspx is included in the application. Parts and states not listed in this MSDN article, if such exist, should be considered undocumented and shouldn't be used (or Raymond Chen will become upset, rightfully). – Andreas Rejbrand Dec 02 '10 at 13:11
17

You're looking for this.

Screenshot

Community
  • 1
  • 1
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Also a nice application. Might not be updated for Windows 7 addition, though. – Andreas Rejbrand Oct 24 '10 at 18:50
  • But this is not in the language of the Windows API (http://msdn.microsoft.com/en-us/library/bb773210(VS.85).aspx), but in the language of .NET, right? – Andreas Rejbrand Oct 24 '10 at 18:58
  • @Andreas: It's written in .Net, but the underlying elements are identical. I don't know about Windows 7. – SLaks Oct 24 '10 at 19:01
  • But it is good to have one Win API and one .NET answer. It might not be obvious which Win API constant corresponds to which .NET identifier, and vice versa. – Andreas Rejbrand Oct 24 '10 at 19:02
  • 5
    Windows Forms' VisualStyles namespace is falling behind pretty badly. It doesn't cover Vista additions either. Same kind of problem as Environment.GetFolderPath(). Making this OS independent is just not that easy. – Hans Passant Oct 24 '10 at 19:23
10

Mike Lische, who wrote the first Theme support for Delphi (which was later absorbed by Borland) has a very good Theme Explorer demo application:

alt text

It's not been updated to support new Windows 7 common controls, but its parts/states explorer is very pretty.

And if i may say, Andreas, a design you might want to copy for yours :)

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • Yes. It is particularly good that the elements are drawn on a checkboard background. There are a few cosmetic bugs when run on Windows 7, though. – Andreas Rejbrand Dec 02 '10 at 13:09
8

Much more comprehensive theme explorer: mCtrl Theme Explorer

mCtrl Theme Explorer

Nedko
  • 567
  • 4
  • 12