[Win32] Visual StyleのPart/Stateを視覚的に確認する

f:id:espresso3389:20100518030842p:image

Windows XP以降、Visual Styleが導入され、ユーザーコード上でも、Visual Styles Referenceにあるような関数群を使うことによって、OSのコントロールと同様の外見のコントロールを描画できるようになっている。
しかしながら、DrawThemeBackground関数などに渡す、iPartId, iStateIdについては、Parts and Statesに一覧があるものの、いったい、具体的に何を示しているのかは非常にわかりにくい。

そこで、この一覧をグラフィカルに表示するコードをやっつけで作ってみた。コンパイルは、VS2008/VS2010で確認した。VS2005でもWindows SDKを導入すればコンパイルできるかな??

#include <windows.h>
#include <commctrl.h>
#include <uxtheme.h>
#include <vsstyle.h>
#include <vssym32.h>
#include <process.h>
#include <stdio.h>
#include <tchar.h>
#include <string.h>
#include <vector>

#pragma comment(lib, "gdi32.lib")
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "comctl32.lib")
#pragma comment(lib, "uxtheme.lib")

#define LNULL NULL
#define DEF_THEME(class_,part_, ...) {L##class_, part_, {__VA_ARGS__}, #part_, "" #__VA_ARGS__}
#define DEF_THEME_NULL(part_, ...) {NULL, part_, {__VA_ARGS__}, #part_, "" #__VA_ARGS__}
const struct THEMEINFO_STRUCT
{
  LPCWSTR tClass;
  int tPart;
  int tStates[20];
  LPCSTR partName;
  LPCSTR tStateNames;
}
g_tinfo_template[] = {
DEF_THEME("BUTTON", BP_CHECKBOX, CBS_CHECKEDDISABLED, CBS_CHECKEDHOT, CBS_CHECKEDNORMAL, CBS_CHECKEDPRESSED, CBS_MIXEDDISABLED, CBS_MIXEDHOT, CBS_MIXEDNORMAL, CBS_MIXEDPRESSED, CBS_UNCHECKEDDISABLED, CBS_UNCHECKEDHOT, CBS_UNCHECKEDNORMAL, CBS_UNCHECKEDPRESSED),
DEF_THEME_NULL(BP_COMMANDLINK, CMDLS_DEFAULTED, CMDLS_DEFAULTED_ANIMATING, CMDLS_DISABLED, CMDLS_HOT, CMDLS_NORMAL, CMDLS_PRESSED),
DEF_THEME_NULL(BP_COMMANDLINKGLYPH, CMDLGS_DEFAULTED, CMDLGS_DISABLED, CMDLGS_HOT, CMDLGS_NORMAL, CMDLGS_PRESSED),
DEF_THEME_NULL(BP_GROUPBOX, GBS_DISABLED, GBS_NORMAL),
DEF_THEME_NULL(BP_PUSHBUTTON, PBS_DEFAULTED, PBS_DISABLED, PBS_HOT, PBS_NORMAL, PBS_PRESSED),
DEF_THEME_NULL(BP_RADIOBUTTON, RBS_CHECKEDDISABLED, RBS_CHECKEDHOT, RBS_CHECKEDNORMAL, RBS_CHECKEDPRESSED, RBS_UNCHECKEDDISABLED, RBS_UNCHECKEDHOT, RBS_UNCHECKEDNORMAL, RBS_UNCHECKEDPRESSED),
DEF_THEME_NULL(BP_USERBUTTON),
DEF_THEME("CLOCK", CLP_TIME, CLS_NORMAL, CLS_HOT, CLS_PRESSED),
DEF_THEME("COMBOBOX", CP_BACKGROUND),
DEF_THEME_NULL(CP_BORDER, CBB_DISABLED, CBB_FOCUSED, CBB_HOT, CBB_NORMAL),
DEF_THEME_NULL(CP_CUEBANNER, CBCB_DISABLED, CBCB_HOT, CBCB_NORMAL, CBCB_PRESSED),
DEF_THEME_NULL(CP_DROPDOWNBUTTON, CBXS_DISABLED, CBXS_HOT, CBXS_NORMAL, CBXS_PRESSED),
DEF_THEME_NULL(CP_DROPDOWNBUTTONLEFT, CBXSL_DISABLED, CBXSL_HOT, CBXSL_NORMAL, CBXSL_PRESSED),
DEF_THEME_NULL(CP_DROPDOWNBUTTONRIGHT, CBXSR_DISABLED, CBXSR_HOT, CBXSR_NORMAL, CBXSR_PRESSED),
DEF_THEME_NULL(CP_TRANSPARENTBACKGROUND, CBTBS_DISABLED, CBTBS_FOCUSED, CBTBS_HOT, CBTBS_NORMAL),
DEF_THEME_NULL(CP_READONLY, CBRO_DISABLED, CBRO_HOT, CBRO_NORMAL, CBRO_PRESSED),
DEF_THEME("COMMUNICATIONS", CSST_TAB, CSTB_HOT, CSTB_NORMAL, CSTB_SELECTED),
DEF_THEME("CONTROLPANEL", CPANEL_BANNERAREA),
DEF_THEME_NULL(CPANEL_BODYTEXT),
DEF_THEME_NULL(CPANEL_BODYTITLE),
DEF_THEME_NULL(CPANEL_BUTTON),
DEF_THEME_NULL(CPANEL_CONTENTLINK, CPCL_DISABLED, CPCL_HOT, CPCL_NORMAL, CPCL_PRESSED),
DEF_THEME_NULL(CPANEL_CONTENTPANE),
DEF_THEME_NULL(CPANEL_CONTENTPANELABEL),
DEF_THEME_NULL(CPANEL_CONTENTPANELINE),
DEF_THEME_NULL(CPANEL_GROUPTEXT),
DEF_THEME_NULL(CPANEL_HELPLINK, CPHL_DISABLED, CPHL_HOT, CPHL_NORMAL, CPHL_PRESSED),
DEF_THEME_NULL(CPANEL_LARGECOMMANDAREA),
DEF_THEME_NULL(CPANEL_MESSAGETEXT),
DEF_THEME_NULL(CPANEL_NAVIGATIONPANE),
DEF_THEME_NULL(CPANEL_NAVIGATIONPANELABEL),
DEF_THEME_NULL(CPANEL_NAVIGATIONPANELINE),
DEF_THEME_NULL(CPANEL_SECTIONTITLELINK, CPSTL_HOT, CPSTL_NORMAL),
DEF_THEME_NULL(CPANEL_SMALLCOMMANDAREA),
DEF_THEME_NULL(CPANEL_TASKLINK, CPTL_DISABLED, CPTL_HOT, CPTL_NORMAL, CPTL_PAGE, CPTL_PRESSED),
DEF_THEME_NULL(CPANEL_TITLE),
DEF_THEME("DATEPICKER", DP_DATEBORDER, DPDB_DISABLED, DPDB_FOCUSED, DPDB_HOT, DPDB_NORMAL),
DEF_THEME_NULL(DP_DATETEXT, DPDT_DISABLED, DPDT_NORMAL, DPDT_SELECTED),
DEF_THEME_NULL(DP_SHOWCALENDARBUTTONRIGHT, DPSCBR_DISABLED, DPSCBR_HOT, DPSCBR_NORMAL, DPSCBR_PRESSED),
DEF_THEME("DRAGDROP", DD_COPY, DDCOPY_HIGHLIGHT, DDCOPY_NOHIGHLIGHT),
DEF_THEME_NULL(DD_CREATELINK, DDCREATELINK_HIGHLIGHT, DDCREATELINK_NOHIGHLIGHT),
DEF_THEME_NULL(DD_IMAGEBG),
DEF_THEME_NULL(DD_MOVE, DDMOVE_HIGHLIGHT, DDMOVE_NOHIGHLIGHT),
DEF_THEME_NULL(DD_NONE, DDNONE_HIGHLIGHT, DDNONE_NOHIGHLIGHT),
DEF_THEME_NULL(DD_TEXTBG),
DEF_THEME_NULL(DD_UPDATEMETADATA, DDUPDATEMETADATA_HIGHLIGHT, DDUPDATEMETADATA_NOHIGHLIGHT),
DEF_THEME_NULL(DD_WARNING, DDWARNING_HIGHLIGHT, DDWARNING_NOHIGHLIGHT),
DEF_THEME("EDIT", EP_BACKGROUND, EBS_ASSIST, EBS_DISABLED, EBS_FOCUSED, EBS_HOT, EBS_NORMAL, EBS_READONLY),
DEF_THEME_NULL(EP_BACKGROUNDWITHBORDER, EBWBS_DISABLED, EBWBS_FOCUSED, EBWBS_HOT, EBWBS_NORMAL),
DEF_THEME_NULL(EP_CARET),
DEF_THEME_NULL(EP_EDITBORDER_HSCROLL, EPSH_DISABLED, EPSH_FOCUSED, EPSH_HOT, EPSH_NORMAL),
DEF_THEME_NULL(EP_EDITBORDER_HVSCROLL, EPSHV_DISABLED, EPSHV_FOCUSED, EPSHV_HOT, EPSHV_NORMAL),
DEF_THEME_NULL(EP_EDITBORDER_NOSCROLL, EPSN_DISABLED, EPSN_FOCUSED, EPSN_HOT, EPSN_NORMAL),
DEF_THEME_NULL(EP_EDITBORDER_VSCROLL, EPSV_DISABLED, EPSV_FOCUSED, EPSV_HOT, EPSV_NORMAL),
DEF_THEME_NULL(EP_EDITTEXT, ETS_ASSIST, ETS_CUEBANNER, ETS_DISABLED, ETS_FOCUSED, ETS_HOT, ETS_NORMAL, ETS_READONLY, ETS_SELECTED),
DEF_THEME_NULL(EP_PASSWORD),
DEF_THEME("EXPLORERBAR", EBP_HEADERBACKGROUND),
DEF_THEME_NULL(EBP_HEADERCLOSE, EBHC_HOT, EBHC_NORMAL, EBHC_PRESSED),
DEF_THEME_NULL(EBP_HEADERPIN, EBHP_HOT, EBHP_NORMAL, EBHP_PRESSED, EBHP_SELECTEDHOT, EBHP_SELECTEDNORMAL, EBHP_SELECTEDPRESSED),
DEF_THEME_NULL(EBP_IEBARMENU, EBM_HOT, EBM_NORMAL, EBM_PRESSED),
DEF_THEME_NULL(EBP_NORMALGROUPBACKGROUND),
DEF_THEME_NULL(EBP_NORMALGROUPCOLLAPSE, EBNGC_HOT, EBNGC_NORMAL, EBNGC_PRESSED),
DEF_THEME_NULL(EBP_NORMALGROUPEXPAND, EBNGE_HOT, EBNGE_NORMAL, EBNGE_PRESSED),
DEF_THEME_NULL(EBP_NORMALGROUPHEAD),
DEF_THEME_NULL(EBP_SPECIALGROUPBACKGROUND),
DEF_THEME_NULL(EBP_SPECIALGROUPCOLLAPSE, EBSGC_HOT, EBSGC_NORMAL, EBSGC_PRESSED),
DEF_THEME_NULL(EBP_SPECIALGROUPEXPAND, EBSGE_HOT, EBSGE_NORMAL, EBSGE_PRESSED),
DEF_THEME_NULL(EBP_SPECIALGROUPHEAD),
DEF_THEME("FLYOUT", FLYOUT_BODY, FBS_EMPHASIZED, FBS_NORMAL),
DEF_THEME_NULL(FLYOUT_DIVIDER),
DEF_THEME_NULL(FLYOUT_HEADER),
DEF_THEME_NULL(FLYOUT_LABEL, FLS_DISABLED, FLS_EMPHASIZED, FLS_NORMAL, FLS_SELECTED),
DEF_THEME_NULL(FLYOUT_LINK, FLYOUTLINK_HOVER, FLYOUTLINK_NORMAL),
DEF_THEME_NULL(FLYOUT_LINKAREA),
DEF_THEME_NULL(FLYOUT_LINKHEADER, FLH_HOVER, FLH_NORMAL),
DEF_THEME_NULL(FLYOUT_WINDOW),
  /*
DEF_THEME("GLOBALS", GP_BORDER, BSS_FLAT, BSS_RAISED, BSS_SUNKEN),
DEF_THEME_NULL(GP_LINEHORZ, LHS_FLAT, LHS_RAISED, LHS_SUNKEN),
DEF_THEME_NULL(GP_LINEVERT, LVS_FLAT, LVS_RAISED, LVS_SUNKEN),
*/
DEF_THEME("HEADER", HP_HEADERDROPDOWN, HDDS_HOT, HDDS_NORMAL, HDDS_SOFTHOT),
DEF_THEME_NULL(HP_HEADERDROPDOWNFILTER, HDDFS_HOT, HDDFS_NORMAL, HDDFS_SOFTHOT),
DEF_THEME_NULL(HP_HEADERITEM, HIS_HOT, HIS_ICONHOT, HIS_ICONNORMAL, HIS_ICONPRESSED, HIS_ICONSORTEDHOT, HIS_ICONSORTEDNORMAL, HIS_ICONSORTEDPRESSED, HIS_NORMAL, HIS_PRESSED, HIS_SORTEDNORMAL, HIS_SORTEDHOT, HIS_SORTEDPRESSED),
DEF_THEME_NULL(HP_HEADERITEMLEFT, HILS_HOT, HILS_NORMAL, HILS_PRESSED),
DEF_THEME_NULL(HP_HEADERITEMRIGHT, HIRS_HOT, HIRS_NORMAL, HIRS_PRESSED),
DEF_THEME_NULL(HP_HEADEROVERFLOW, HOFS_HOT, HOFS_NORMAL),
DEF_THEME_NULL(HP_HEADERSORTARROW, HSAS_SORTEDDOWN, HSAS_SORTEDUP),
DEF_THEME("LISTBOX", LBCP_BORDER_HSCROLL, LBPSH_DISABLED, LBPSH_FOCUSED, LBPSH_HOT, LBPSH_NORMAL),
DEF_THEME_NULL(LBCP_BORDER_HVSCROLL, LBPSHV_DISABLED, LBPSHV_FOCUSED, LBPSHV_HOT, LBPSHV_NORMAL),
DEF_THEME_NULL(LBCP_BORDER_NOSCROLL, LBPSN_DISABLED, LBPSN_FOCUSED, LBPSN_HOT, LBPSN_NORMAL),
DEF_THEME_NULL(LBCP_BORDER_VSCROLL, LBPSV_DISABLED, LBPSV_FOCUSED, LBPSV_HOT, LBPSV_NORMAL),
DEF_THEME_NULL(LBCP_ITEM, LBPSI_HOT, LBPSI_HOTSELECTED, LBPSI_SELECTED, LBPSI_SELECTEDNOTFOCUS),
DEF_THEME("LISTVIEW", LVP_COLLAPSEBUTTON, LVCB_HOVER, LVCB_NORMAL, LVCB_PUSHED),
DEF_THEME_NULL(LVP_COLUMNDETAIL),
DEF_THEME_NULL(LVP_EMPTYTEXT),
DEF_THEME_NULL(LVP_EXPANDBUTTON, LVEB_HOVER, LVEB_NORMAL, LVEB_PUSHED),
DEF_THEME_NULL(LVP_GROUPHEADER, LVGH_CLOSE, LVGH_CLOSEHOT, LVGH_CLOSESELECTED, LVGH_CLOSESELECTEDHOT, LVGH_CLOSESELECTEDNOTFOCUSED, LVGH_CLOSESELECTEDNOTFOCUSEDHOT, LVGH_CLOSEMIXEDSELECTION, LVGH_CLOSEMIXEDSELECTIONHOT, LVGH_OPEN, LVGH_OPENHOT, LVGH_OPENSELECTED, LVGH_OPENSELECTEDHOT, LVGH_OPENSELECTEDNOTFOCUSED, LVGH_OPENSELECTEDNOTFOCUSEDHOT, LVGH_OPENMIXEDSELECTION, LVGH_OPENMIXEDSELECTIONHOT),
DEF_THEME_NULL(LVP_GROUPHEADERLINE, LVGHL_CLOSE, LVGHL_CLOSEHOT, LVGHL_CLOSESELECTED, LVGHL_CLOSESELECTEDHOT, LVGHL_CLOSESELECTEDNOTFOCUSED, LVGHL_CLOSESELECTEDNOTFOCUSEDHOT, LVGHL_CLOSEMIXEDSELECTION, LVGHL_CLOSEMIXEDSELECTIONHOT, LVGHL_OPEN, LVGHL_OPENHOT, LVGHL_OPENSELECTED, LVGHL_OPENSELECTEDHOT, LVGHL_OPENSELECTEDNOTFOCUSED, LVGHL_OPENSELECTEDNOTFOCUSEDHOT, LVGHL_OPENMIXEDSELECTION, LVGHL_OPENMIXEDSELECTIONHOT),
DEF_THEME_NULL(LVP_LISTGROUP),
DEF_THEME_NULL(LVP_LISTDETAIL),
DEF_THEME_NULL(LVP_LISTITEM, LISS_DISABLED, LISS_HOT, LISS_HOTSELECTED, LISS_NORMAL, LISS_SELECTED, LISS_SELECTEDNOTFOCUS),
DEF_THEME_NULL(LVP_LISTSORTEDDETAIL),
DEF_THEME("MENU", MENU_BARBACKGROUND, MB_ACTIVE, MB_INACTIVE),
DEF_THEME_NULL(MENU_BARITEM, MBI_DISABLED, MBI_DISABLEDHOT, MBI_DISABLEDPUSHED, MBI_HOT, MBI_NORMAL, MBI_PUSHED),
DEF_THEME_NULL(MENU_CHEVRON_TMSCHEMA),
DEF_THEME_NULL(MENU_MENUBARDROPDOWN_TMSCHEMA),
DEF_THEME_NULL(MENU_MENUBARITEM_TMSCHEMA),
DEF_THEME_NULL(MENU_MENUDROPDOWN_TMSCHEMA),
DEF_THEME_NULL(MENU_MENUITEM_TMSCHEMA),
DEF_THEME_NULL(MENU_POPUPBACKGROUND),
DEF_THEME_NULL(MENU_POPUPBORDERS),
DEF_THEME_NULL(MENU_POPUPCHECK, MC_BULLETDISABLED, MC_BULLETNORMAL, MC_CHECKMARKDISABLED, MC_CHECKMARKNORMAL),
DEF_THEME_NULL(MENU_POPUPCHECKBACKGROUND, MCB_BITMAP, MCB_DISABLED, MCB_NORMAL),
DEF_THEME_NULL(MENU_POPUPGUTTER),
DEF_THEME_NULL(MENU_POPUPITEM, MPI_DISABLED, MPI_DISABLEDHOT, MPI_HOT, MPI_NORMAL),
DEF_THEME_NULL(MENU_POPUPSEPARATOR),
DEF_THEME_NULL(MENU_POPUPSUBMENU, MSM_DISABLED, MSM_NORMAL),
DEF_THEME_NULL(MENU_SEPARATOR_TMSCHEMA),
DEF_THEME_NULL(MENU_SYSTEMCLOSE, MSYSC_DISABLED, MSYSC_NORMAL),
DEF_THEME_NULL(MENU_SYSTEMMAXIMIZE, MSYSMX_DISABLED, MSYSMX_NORMAL),
DEF_THEME_NULL(MENU_SYSTEMMINIMIZE, MSYSMN_DISABLED, MSYSMN_NORMAL),
DEF_THEME_NULL(MENU_SYSTEMRESTORE, MSYSR_DISABLED, MSYSR_NORMAL),
DEF_THEME("MENUBAND", MDP_NEWAPPBUTTON, MDS_CHECKED, MDS_DISABLED, MDS_HOT, MDS_HOTCHECKED, MDS_NORMAL, MDS_PRESSED),
DEF_THEME_NULL(MDP_SEPERATOR),
DEF_THEME("NAVIGATION", NAV_BACKBUTTON, NAV_BB_DISABLED, NAV_BB_HOT, NAV_BB_NORMAL, NAV_BB_PRESSED),
DEF_THEME_NULL(NAV_FORWARDBUTTON, NAV_FB_DISABLED, NAV_FB_HOT, NAV_FB_NORMAL, NAV_FB_PRESSED),
DEF_THEME_NULL(NAV_MENUBUTTON, NAV_MB_DISABLED, NAV_MB_HOT, NAV_MB_NORMAL, NAV_MB_PRESSED),
DEF_THEME("PAGE", PGRP_DOWN, DNS_DISABLED, DNS_HOT, DNS_NORMAL, DNS_PRESSED),
DEF_THEME_NULL(PGRP_DOWNHORZ, DNHZS_DISABLED, DNHZS_HOT, DNHZS_NORMAL, DNHZS_PRESSED),
DEF_THEME_NULL(PGRP_UP, UPS_DISABLED, UPS_HOT, UPS_NORMAL, UPS_PRESSED),
DEF_THEME_NULL(PGRP_UPHORZ, UPHZS_DISABLED, UPHZS_HOT, UPHZS_NORMAL, UPHZS_PRESSED),
DEF_THEME("PROGRESS", PP_BAR),
DEF_THEME_NULL(PP_BARVERT),
DEF_THEME_NULL(PP_CHUNK),
DEF_THEME_NULL(PP_CHUNKVERT),
DEF_THEME_NULL(PP_FILL, PBFS_ERROR, PBFS_NORMAL, PBFS_PARTIAL, PBFS_PAUSED),
DEF_THEME_NULL(PP_FILLVERT, PBFVS_ERROR, PBFVS_NORMAL, PBFVS_PARTIAL, PBFVS_PAUSED),
DEF_THEME_NULL(PP_MOVEOVERLAY),
DEF_THEME_NULL(PP_MOVEOVERLAYVERT),
DEF_THEME_NULL(PP_PULSEOVERLAY),
DEF_THEME_NULL(PP_PULSEOVERLAYVERT),
DEF_THEME_NULL(PP_TRANSPARENTBAR, PBBS_NORMAL, PBBS_PARTIAL),
DEF_THEME_NULL(PP_TRANSPARENTBARVERT, PBBVS_NORMAL, PBBVS_PARTIAL),
DEF_THEME("REBAR", RP_BACKGROUND),
DEF_THEME_NULL(RP_BAND),
DEF_THEME_NULL(RP_CHEVRON, CHEVS_HOT, CHEVS_NORMAL, CHEVS_PRESSED),
DEF_THEME_NULL(RP_CHEVRONVERT, CHEVSV_HOT, CHEVSV_NORMAL, CHEVSV_PRESSED),
DEF_THEME_NULL(RP_GRIPPER),
DEF_THEME_NULL(RP_GRIPPERVERT),
DEF_THEME_NULL(RP_SPLITTER, SPLITS_HOT, SPLITS_NORMAL, SPLITS_PRESSED),
DEF_THEME_NULL(RP_SPLITTERVERT, SPLITSV_HOT, SPLITSV_NORMAL, SPLITSV_PRESSED),
DEF_THEME("SCROLLBAR", SBP_ARROWBTN, ABS_DOWNDISABLED, ABS_DOWNHOT, ABS_DOWNNORMAL, ABS_DOWNPRESSED, ABS_DOWNHOVER, ABS_LEFTDISABLED, ABS_LEFTHOT, ABS_LEFTHOVER, ABS_LEFTNORMAL, ABS_LEFTPRESSED, ABS_RIGHTDISABLED, ABS_RIGHTHOT, ABS_RIGHTHOVER, ABS_RIGHTNORMAL, ABS_RIGHTPRESSED, ABS_UPDISABLED, ABS_UPHOT, ABS_UPHOVER, ABS_UPNORMAL, ABS_UPPRESSED),
DEF_THEME_NULL(SBP_GRIPPERHORZ, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
DEF_THEME_NULL(SBP_GRIPPERVERT, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
DEF_THEME_NULL(SBP_LOWERTRACKHORZ, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
DEF_THEME_NULL(SBP_LOWERTRACKVERT, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
DEF_THEME_NULL(SBP_SIZEBOX, SZB_HALFBOTTOMRIGHTALIGN, SZB_HALFBOTTOMLEFTALIGN, SZB_HALFTOPRIGHTALIGN, SZB_HALFTOPLEFTALIGN, SZB_LEFTALIGN, SZB_RIGHTALIGN, SZB_TOPRIGHTALIGN, SZB_TOPLEFTALIGN),
DEF_THEME_NULL(SBP_THUMBBTNHORZ, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
DEF_THEME_NULL(SBP_THUMBBTNVERT, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
DEF_THEME_NULL(SBP_UPPERTRACKHORZ, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
DEF_THEME_NULL(SBP_UPPERTRACKVERT, SCRBS_DISABLED, SCRBS_HOT, SCRBS_HOVER, SCRBS_NORMAL, SCRBS_PRESSED),
// DEF_THEME("SEARCHEDITBOX", SEBP_SEARCHEDITBOXTEXT, SEBTS_FORMATTED),
DEF_THEME("SPIN", SPNP_DOWN, DNS_DISABLED, DNS_HOT, DNS_NORMAL, DNS_PRESSED),
DEF_THEME_NULL(SPNP_DOWNHORZ, DNHZS_DISABLED, DNHZS_HOT, DNHZS_NORMAL, DNHZS_PRESSED),
DEF_THEME_NULL(SPNP_UP, UPS_DISABLED, UPS_HOT, UPS_NORMAL, UPS_PRESSED),
DEF_THEME_NULL(SPNP_UPHORZ, UPHZS_DISABLED, UPHZS_HOT, UPHZS_NORMAL, UPHZS_PRESSED),
DEF_THEME("STARTPANEL", SPP_LOGOFF),
DEF_THEME_NULL(SPP_LOGOFFBUTTONS, SPLS_HOT, SPLS_NORMAL, SPLS_PRESSED),
DEF_THEME_NULL(SPP_MOREPROGRAMS),
DEF_THEME_NULL(SPP_MOREPROGRAMSARROW, SPS_HOT, SPS_NORMAL, SPS_PRESSED),
DEF_THEME_NULL(SPP_PLACESLIST),
DEF_THEME_NULL(SPP_PLACESLISTSEPARATOR),
DEF_THEME_NULL(SPP_PREVIEW),
DEF_THEME_NULL(SPP_PROGLIST),
DEF_THEME_NULL(SPP_PROGLISTSEPARATOR),
DEF_THEME_NULL(SPP_USERPANE),
DEF_THEME_NULL(SPP_USERPICTURE),
DEF_THEME("STATUS", SP_GRIPPER),
DEF_THEME_NULL(SP_GRIPPERPANE),
DEF_THEME_NULL(SP_PANE),
DEF_THEME("TAB", TABP_AEROWIZARDBODY),
DEF_THEME_NULL(TABP_BODY),
DEF_THEME_NULL(TABP_PANE),
DEF_THEME_NULL(TABP_TABITEM, TIS_DISABLED, TIS_FOCUSED, TIS_HOT, TIS_NORMAL, TIS_SELECTED),
DEF_THEME_NULL(TABP_TABITEMBOTHEDGE, TIBES_DISABLED, TIBES_FOCUSED, TIBES_HOT, TIBES_NORMAL, TIBES_SELECTED),
DEF_THEME_NULL(TABP_TABITEMLEFTEDGE, TILES_DISABLED, TILES_FOCUSED, TILES_HOT, TILES_NORMAL, TILES_SELECTED),
DEF_THEME_NULL(TABP_TABITEMRIGHTEDGE, TIRES_DISABLED, TIRES_FOCUSED, TIRES_HOT, TIRES_NORMAL, TIRES_SELECTED),
DEF_THEME_NULL(TABP_TOPTABITEM, TTIS_DISABLED, TTIS_FOCUSED, TTIS_HOT, TTIS_NORMAL, TTIS_SELECTED),
DEF_THEME_NULL(TABP_TOPTABITEMBOTHEDGE, TTIBES_DISABLED, TTIBES_FOCUSED, TTIBES_HOT, TTIBES_NORMAL, TTIBES_SELECTED),
DEF_THEME_NULL(TABP_TOPTABITEMLEFTEDGE, TTILES_DISABLED, TTILES_FOCUSED, TTILES_HOT, TTILES_NORMAL, TTILES_SELECTED),
DEF_THEME_NULL(TABP_TOPTABITEMRIGHTEDGE, TTIRES_DISABLED, TTIRES_FOCUSED, TTIRES_HOT, TTIRES_NORMAL, TTIRES_SELECTED),
DEF_THEME("TASKBAND", TDP_GROUPCOUNT),
DEF_THEME_NULL(TDP_FLASHBUTTON),
DEF_THEME_NULL(TDP_FLASHBUTTONGROUPMENU),
DEF_THEME("TASKBAR", TBP_BACKGROUNDBOTTOM),
DEF_THEME_NULL(TBP_BACKGROUNDLEFT),
DEF_THEME_NULL(TBP_BACKGROUNDRIGHT),
// DEF_THEME_NULL(TBP_BACKGROUNDTOP),
DEF_THEME_NULL(TBP_SIZINGBARBOTTOM),
// DEF_THEME_NULL(TBP_SIZINGBARBOTTOMLEFT),
DEF_THEME_NULL(TBP_SIZINGBARRIGHT),
DEF_THEME_NULL(TBP_SIZINGBARTOP),
DEF_THEME("TASKDIALOG", TDLG_BUTTONSECTION),
DEF_THEME_NULL(TDLG_BUTTONWRAPPER),
DEF_THEME_NULL(TDLG_COMMANDLINKPANE),
DEF_THEME_NULL(TDLG_CONTENTICON),
DEF_THEME_NULL(TDLG_CONTENTPANE, TDLGCPS_STANDALONE),
DEF_THEME_NULL(TDLG_CONTROLPANE),
DEF_THEME_NULL(TDLG_EXPANDEDCONTENT),
DEF_THEME_NULL(TDLG_EXPANDEDFOOTERAREA),
DEF_THEME_NULL(TDLG_EXPANDOBUTTON, TDLGEBS_EXPANDEDHOVER, TDLGEBS_EXPANDEDNORMAL, TDLGEBS_EXPANDEDPRESSED, TDLGEBS_HOVER, TDLGEBS_NORMAL, TDLGEBS_PRESSED),
DEF_THEME_NULL(TDLG_EXPANDOTEXT),
DEF_THEME_NULL(TDLG_FOOTNOTEAREA),
DEF_THEME_NULL(TDLG_FOOTNOTEPANE),
DEF_THEME_NULL(TDLG_FOOTNOTESEPARATOR),
DEF_THEME_NULL(TDLG_IMAGEALIGNMENT),
DEF_THEME_NULL(TDLG_MAINICON),
DEF_THEME_NULL(TDLG_MAININSTRUCTIONPANE),
DEF_THEME_NULL(TDLG_PRIMARYPANEL),
DEF_THEME_NULL(TDLG_PROGRESSBAR),
DEF_THEME_NULL(TDLG_RADIOBUTTONPANE),
DEF_THEME_NULL(TDLG_SECONDARYPANEL),
DEF_THEME_NULL(TDLG_VERIFICATIONTEXT),
DEF_THEME("TEXTSTYLE", TEXT_BODYTITLE),
DEF_THEME_NULL(TEXT_BODYTEXT),
DEF_THEME_NULL(TEXT_CONTROLLABEL, TS_CONTROLLABEL_DISABLED, TS_CONTROLLABEL_NORMAL),
DEF_THEME_NULL(TEXT_EXPANDED),
DEF_THEME_NULL(TEXT_HYPERLINKTEXT, TS_HYPERLINK_DISABLED, TS_HYPERLINK_HOT, TS_HYPERLINK_NORMAL, TS_HYPERLINK_PRESSED),
DEF_THEME_NULL(TEXT_INSTRUCTION),
DEF_THEME_NULL(TEXT_LABEL),
DEF_THEME_NULL(TEXT_MAININSTRUCTION),
DEF_THEME_NULL(TEXT_SECONDARYTEXT),
DEF_THEME("TOOLBAR", TP_BUTTON, TS_CHECKED, TS_DISABLED, TS_HOT, TS_HOTCHECKED, TS_NEARHOT, TS_NORMAL, TS_OTHERSIDEHOT, TS_PRESSED),
DEF_THEME_NULL(TP_DROPDOWNBUTTON, TS_CHECKED, TS_DISABLED, TS_HOT, TS_HOTCHECKED, TS_NEARHOT, TS_NORMAL, TS_OTHERSIDEHOT, TS_PRESSED),
DEF_THEME_NULL(TP_DROPDOWNBUTTONGLYPH, TS_CHECKED, TS_DISABLED, TS_HOT, TS_HOTCHECKED, TS_NEARHOT, TS_NORMAL, TS_OTHERSIDEHOT, TS_PRESSED),
DEF_THEME_NULL(TP_SEPARATOR, TS_CHECKED, TS_DISABLED, TS_HOT, TS_HOTCHECKED, TS_NEARHOT, TS_NORMAL, TS_OTHERSIDEHOT, TS_PRESSED),
DEF_THEME_NULL(TP_SEPARATORVERT, TS_CHECKED, TS_DISABLED, TS_HOT, TS_HOTCHECKED, TS_NEARHOT, TS_NORMAL, TS_OTHERSIDEHOT, TS_PRESSED),
DEF_THEME_NULL(TP_SPLITBUTTON, TS_CHECKED, TS_DISABLED, TS_HOT, TS_HOTCHECKED, TS_NEARHOT, TS_NORMAL, TS_OTHERSIDEHOT, TS_PRESSED),
DEF_THEME_NULL(TP_SPLITBUTTONDROPDOWN, TS_CHECKED, TS_DISABLED, TS_HOT, TS_HOTCHECKED, TS_NEARHOT, TS_NORMAL, TS_OTHERSIDEHOT, TS_PRESSED),
DEF_THEME("TOOLTIP", TTP_BALLOON, TTBS_LINK, TTBS_NORMAL),
DEF_THEME_NULL(TTP_BALLOONSTEM, TTBSS_POINTINGUPLEFTWALL, TTBSS_POINTINGUPCENTERED, TTBSS_POINTINGUPRIGHTWALL, TTBSS_POINTINGDOWNRIGHTWALL, TTBSS_POINTINGDOWNCENTERED, TTBSS_POINTINGDOWNLEFTWALL),
DEF_THEME_NULL(TTP_BALLOONTITLE),
DEF_THEME_NULL(TTP_CLOSE, TTCS_HOT, TTCS_NORMAL, TTCS_PRESSED),
DEF_THEME_NULL(TTP_STANDARD, TTSS_LINK, TTSS_NORMAL),
DEF_THEME_NULL(TTP_STANDARDTITLE, TTSS_LINK, TTSS_NORMAL),
DEF_THEME_NULL(TTP_WRENCH, TTWS_NORMAL, TTWS_HOT, TTWS_PRESSED),
DEF_THEME("TRACKBAR", TKP_THUMB, TUS_DISABLED, TUS_FOCUSED, TUS_HOT, TUS_NORMAL, TUS_PRESSED),
DEF_THEME_NULL(TKP_THUMBBOTTOM, TUBS_DISABLED, TUBS_FOCUSED, TUBS_HOT, TUBS_NORMAL, TUBS_PRESSED),
DEF_THEME_NULL(TKP_THUMBLEFT, TUVLS_DISABLED, TUVLS_FOCUSED, TUVLS_HOT, TUVLS_NORMAL, TUVLS_PRESSED),
DEF_THEME_NULL(TKP_THUMBRIGHT, TUVRS_DISABLED, TUVRS_FOCUSED, TUVRS_HOT, TUVRS_NORMAL, TUVRS_PRESSED),
DEF_THEME_NULL(TKP_THUMBTOP, TUTS_DISABLED, TUTS_FOCUSED, TUTS_HOT, TUTS_NORMAL, TUTS_PRESSED),
DEF_THEME_NULL(TKP_THUMBVERT, TUVS_DISABLED, TUVS_FOCUSED, TUVS_HOT, TUVS_NORMAL, TUVS_PRESSED),
DEF_THEME_NULL(TKP_TICS, TSS_NORMAL),
DEF_THEME_NULL(TKP_TICSVERT, TSVS_NORMAL),
DEF_THEME_NULL(TKP_TRACK, TRS_NORMAL),
DEF_THEME_NULL(TKP_TRACKVERT, TRVS_NORMAL),
DEF_THEME("TRAYNOTIFY", TNP_ANIMBACKGROUND),
DEF_THEME_NULL(TNP_BACKGROUND),
DEF_THEME("TREEVIEW", TVP_BRANCH),
DEF_THEME_NULL(TVP_GLYPH, GLPS_CLOSED, GLPS_OPENED),
DEF_THEME_NULL(TVP_HOTGLYPH, HGLPS_CLOSED, HGLPS_OPENED),
DEF_THEME_NULL(TVP_TREEITEM, TREIS_DISABLED, TREIS_HOT, TREIS_NORMAL, TREIS_SELECTED, TREIS_SELECTEDNOTFOCUS, TREIS_HOTSELECTED),
DEF_THEME("WINDOW", WP_CAPTION, CS_ACTIVE, CS_DISABLED, CS_INACTIVE),
DEF_THEME_NULL(WP_CAPTIONSIZINGTEMPLATE),
DEF_THEME_NULL(WP_CLOSEBUTTON, CBS_DISABLED, CBS_HOT, CBS_NORMAL, CBS_PUSHED),
DEF_THEME_NULL(WP_DIALOG),
DEF_THEME_NULL(WP_FRAME, FS_ACTIVE, FS_INACTIVE),
DEF_THEME_NULL(WP_FRAMEBOTTOM),
DEF_THEME_NULL(WP_FRAMEBOTTOMSIZINGTEMPLATE),
DEF_THEME_NULL(WP_FRAMELEFT),
DEF_THEME_NULL(WP_FRAMELEFTSIZINGTEMPLATE),
DEF_THEME_NULL(WP_FRAMERIGHT),
DEF_THEME_NULL(WP_FRAMERIGHTSIZINGTEMPLATE),
DEF_THEME_NULL(WP_HELPBUTTON, HBS_DISABLED, HBS_HOT, HBS_NORMAL, HBS_PUSHED),
DEF_THEME_NULL(WP_HORZSCROLL, HSS_DISABLED, HSS_HOT, HSS_NORMAL, HSS_PUSHED),
DEF_THEME_NULL(WP_HORZTHUMB, HTS_DISABLED, HTS_HOT, HTS_NORMAL, HTS_PUSHED),
DEF_THEME_NULL(WP_MAXBUTTON, MAXBS_DISABLED, MAXBS_HOT, MAXBS_NORMAL, MAXBS_PUSHED),
DEF_THEME_NULL(WP_MAXCAPTION, MXCS_ACTIVE, MXCS_DISABLED, MXCS_INACTIVE),
DEF_THEME_NULL(WP_MDICLOSEBUTTON),
DEF_THEME_NULL(WP_MDIHELPBUTTON),
DEF_THEME_NULL(WP_MDIMINBUTTON),
DEF_THEME_NULL(WP_MDIRESTOREBUTTON),
DEF_THEME_NULL(WP_MDISYSBUTTON),
DEF_THEME_NULL(WP_MINBUTTON, MINBS_DISABLED, MINBS_HOT, MINBS_NORMAL, MINBS_PUSHED),
DEF_THEME_NULL(WP_MINCAPTION, MNCS_ACTIVE, MNCS_DISABLED, MNCS_INACTIVE),
DEF_THEME_NULL(WP_RESTOREBUTTON, RBS_DISABLED, RBS_HOT, RBS_NORMAL, RBS_PUSHED),
DEF_THEME_NULL(WP_SMALLCAPTION),
DEF_THEME_NULL(WP_SMALLCAPTIONSIZINGTEMPLATE),
DEF_THEME_NULL(WP_SMALLCLOSEBUTTON),
DEF_THEME_NULL(WP_SMALLFRAMEBOTTOM),
DEF_THEME_NULL(WP_SMALLFRAMEBOTTOMSIZINGTEMPLATE),
DEF_THEME_NULL(WP_SMALLFRAMELEFT),
DEF_THEME_NULL(WP_SMALLFRAMELEFTSIZINGTEMPLATE),
DEF_THEME_NULL(WP_SMALLFRAMERIGHT),
DEF_THEME_NULL(WP_SMALLFRAMERIGHTSIZINGTEMPLATE),
DEF_THEME_NULL(WP_SMALLMAXCAPTION),
DEF_THEME_NULL(WP_SMALLMINCAPTION),
DEF_THEME_NULL(WP_SYSBUTTON, SBS_DISABLED, SBS_HOT, SBS_NORMAL, SBS_PUSHED),
DEF_THEME_NULL(WP_VERTSCROLL, VSS_DISABLED, VSS_HOT, VSS_NORMAL, VSS_PUSHED),
DEF_THEME_NULL(WP_VERTTHUMB, VTS_DISABLED, VTS_HOT, VTS_NORMAL, VTS_PUSHED)
};

const size_t CLASSANDPART_COUNT = sizeof(g_tinfo_template) / sizeof(THEMEINFO_STRUCT);
HFONT g_hSysFont = NULL;

struct RUNTIME_THEMEINFO
{
  LPCWSTR className;
  int part;
  int state;
  LPCTSTR partName;
  LPCTSTR stateName;
};
std::vector<RUNTIME_THEMEINFO> g_tinfo;
size_t g_idx = 0;

BOOL IsClearTypeEnabled()
{
  BOOL check = FALSE;
  UINT check2 = 0;
  if(!SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &check,0))
    return FALSE;
  if(!check)
    return FALSE;
  
  if(!SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &check2,0))
    return FALSE;
  return (check2 == FE_FONTSMOOTHINGCLEARTYPE);
}

void InitSysFont()
{
  NONCLIENTMETRICS ncm;
  ncm.cbSize = sizeof(NONCLIENTMETRICS);
#if(WINVER >= 0x0600)
  ncm.cbSize -= 4; // Quick hack for Windows SDK 6.0
#endif
  if(SystemParametersInfo(
    SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
  {
    // Enable ClearType or simple antialias
    ncm.lfMenuFont.lfQuality = IsClearTypeEnabled() ? CLEARTYPE_QUALITY : ANTIALIASED_QUALITY;
    g_hSysFont = CreateFontIndirect(&ncm.lfMenuFont);
  }
}

void DoPaint(HWND hwnd)
{
  RECT rc;
  GetClientRect(hwnd, &rc);
  
  rc.left += 16;
  rc.top += 50;
  rc.right -= 16;
  rc.bottom -= 16;
  
  RUNTIME_THEMEINFO& t = g_tinfo[g_idx];
  
  HTHEME hTheme = OpenThemeData(hwnd, t.className);

  PAINTSTRUCT ps;
  BeginPaint(hwnd, &ps);
  
  HGDIOBJ hOldFont = SelectObject(ps.hdc, g_hSysFont);
  SetBkMode(ps.hdc, TRANSPARENT);
  SetTextColor(ps.hdc, 0);

  TextOutW(ps.hdc, 0, 0, t.className, wcslen(t.className));
  TextOutA(ps.hdc, 0, 16, t.partName, strlen(t.partName));
  TextOutA(ps.hdc, 0, 32, t.stateName, strlen(t.stateName));

  DrawThemeBackground(
    hTheme, ps.hdc, t.part, t.state, &rc, &ps.rcPaint);
  
  RECT rcContent;
  GetThemeBackgroundContentRect(
    hTheme, ps.hdc, t.part, t.state, &rc, &rcContent);
  rcContent.left += 16;
  rcContent.top += 16;

  DrawThemeText(
    hTheme, ps.hdc, t.part, t.state,
    t.className, -1, 0, 0, &rcContent);

  SelectObject(ps.hdc, hOldFont);
  EndPaint(hwnd, &ps);
  
  CloseThemeData(hTheme);
}

// level: 0,class 1,part 2,state
void next(HWND hwnd, bool inc, int level)
{
  size_t add = inc ? 1 : g_tinfo.size() - 1;
  RUNTIME_THEMEINFO& last = g_tinfo[g_idx];
  for(;;)
  {
    g_idx = (g_idx + add) % g_tinfo.size();
    RUNTIME_THEMEINFO& cur = g_tinfo[g_idx];
    if(level == 0 && last.className != cur.className)
      break;
    else if(level == 1 && last.part != cur.part)
      break;
    else if(level == 2)
      break;
  }
  InvalidateRect(hwnd, NULL, TRUE);
}

static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg)
  {
  case WM_CREATE:
    break;

  case WM_PAINT:
    DoPaint(hwnd);
    break;
  
  case WM_LBUTTONDOWN:
    next(hwnd, true, 2);
    break;
    
  case WM_RBUTTONDOWN:
    next(hwnd, false, 2);
    break;

  case WM_KEYDOWN:
    switch(wParam)
    {
    case VK_HOME:
      g_idx = 0;
      InvalidateRect(hwnd, NULL, TRUE);
      break;
    case VK_END:
      g_idx = g_tinfo.size() - 1;
      InvalidateRect(hwnd, NULL, TRUE);
      break;
    case VK_PRIOR:
      next(hwnd, false, 0);
      break;
    case VK_NEXT:
      next(hwnd, true, 0);
      break;
    case VK_SPACE:
    case VK_RIGHT:
      next(hwnd, true, 2);
      break;
    case VK_BACK:
    case VK_LEFT:
      next(hwnd, false, 2);
      break;
    case VK_UP:
      next(hwnd, false, 1);
      break;
    case VK_DOWN:
      next(hwnd, true, 1);
      break;
    }
    break;

  case WM_CLOSE:
    DestroyWindow(hwnd);
    break;

  case WM_DESTROY:
    PostQuitMessage(0);
    break;

  default:
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
  }
  return 0;
}

int main()
{
  HINSTANCE hInstance = NULL;
  int nCmdShow = SW_SHOW;

  int state = 0, classAndPart = 0;
  int count = 0;
  LPCWSTR lastClass = NULL;
  do
  {
    const THEMEINFO_STRUCT& t = g_tinfo_template[classAndPart];
    LPCWSTR className = t.tClass;
    if(!className) className = lastClass;
    lastClass = className;
    
    char* buf = new char[strlen(t.tStateNames) + 1];
    strcpy(buf, t.tStateNames);
    char* stateName = buf;
    for(int i = 0; i < state; i++)
    {
      stateName = strchr(stateName, ',');
      if(!stateName)
        break;
      stateName++;
      while(*stateName == ' ') stateName++;
    }
    if(stateName && stateName[0])
    {
      char* p = strchr(stateName, ',');
      if(p) *p = 0;
    }
    else
    {
      stateName = "0";
    }
    
    RUNTIME_THEMEINFO rti = {
      className, t.tPart, t.tStates[state], t.partName, stateName};
    g_tinfo.push_back(rti);

    count++;
    state++;
    if(state > 0 && g_tinfo_template[classAndPart].tStates[state] == 0)
    {
      classAndPart++;
      state = 0;
    }
  }
  while(classAndPart < CLASSANDPART_COUNT);
  printf("%u\n", count);

  InitCommonControls();
  
  InitSysFont();
  
  LPCTSTR className = _T("uxtheme_viewer_class");
  
  WNDCLASSEX wc;
  ZeroMemory(&wc, sizeof(wc));
  wc.cbSize        = sizeof(wc);
  wc.style         = CS_HREDRAW | CS_VREDRAW;
  wc.lpfnWndProc   = WndProc;
  wc.hInstance     = hInstance;
  wc.hIcon         = NULL;
  wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
  wc.lpszClassName = className;
  RegisterClassEx(&wc);

  HWND hwnd = CreateWindow(className,
    _T("UxTheme Viewer"),
    WS_OVERLAPPED | WS_SYSMENU,
    0, 0, 400, 400,
    NULL, NULL, hInstance,
    NULL);

  ShowWindow(hwnd, nCmdShow);
  UpdateWindow(hwnd);

  MSG msg;
  while(GetMessage(&msg, NULL, 0, 0))
  {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return msg.wParam;
}