Now, a modified version of David Y. Zhao's Visual Styles support class[^]
Apologies if there are some irrelevant export directives and missing constants. Let me know if there is anything important missing. Somewhere I think there's an operating system version test using a class of mine - you can easily find code elsewhere to do an equivalent test.
#ifndef _VISUALSTYLE_XP_H_
#define _VISUALSTYLE_XP_H_
#pragma once
#include <uxtheme.h>
#if _MSC_VER >= 1500
#if ((NTDDI_VERSION >= NTDDI_LONGHORN || defined(__VSSYM32_H__)) && !defined(SCHEMA_VERIFY_VSSYM32))
#include <vssym32.h>
#else
#include <tmschema.h>
#endif
#else
#include "tmschema.h"
#endif
// DP: 22/11/2005 Include temporary theme handle helper class for convenience
#include "TempThemeHandle.h"
enum EXP_State {
XPS_NORMAL =1,
XPS_HOT =2,
XPS_PRESSED =3,
XPS_DISABLED=4
};
enum EXP_ToolBarState {
XPS_TB_NORMAL =1,
XPS_TB_HOT =2,
XPS_TB_PRESSED =3,
XPS_TB_DISABLED =4,
XPS_TB_CHECKED =5,
XPS_TB_HOTCHECKED =6
};
enum EXP_SliderThumbState {
XPS_ST_NORMAL =1,
XPS_ST_HOT =2,
XPS_ST_PRESSED =3,
XPS_ST_FOCUS =4,
XPS_ST_DISABLED=5
};
enum EXP_CheckBoxIndex {
XPS_CB_Unchecked =0,
XPS_CB_Checked =4,
XPS_CB_Mixed =8
};
enum EXP_SBArrowsIndex {
XPS_SBArrows_Up =0,
XPS_SBArrows_Down =4,
XPS_SBArrows_Left =8,
XPS_SBArrows_Right =12
};
// DP 19/07/2004 Some constants Microsoft seems to have forgotten
/* GLOBALS parts */
#define GP_BORDER 1
#define GP_LINEHORZ 2
#define GP_LINEVERT 3
/* GLOBALS BORDER states */
#define BSS_FLAT 1
#define BSS_RAISED 2
#define BSS_SUNKEN 3
/* GLOBALS LINEHORZ states */
#define LHS_FLAT 1
#define LHS_RAISED 2
#define LHS_SUNKEN 3
/* GLOBAL LINEVERT states */
#define LVS_FLAT 1
#define LVS_RAISED 2
#define LVS_SUNKEN 3
// DP 21/05/2004: Modified to make into singleton and export
// DP 24/09/2004: Disable warnings for compiling at level 4
#pragma warning (disable : 4100)
class CVisualStylesXP
{
// DP 21/05/2004: Modified to make into singleton and export
public:
static CVisualStylesXP * GetInstance ();
static void DeleteInstance ();
// DP: 16/07/2004 Added this function to wrap the whole process in one function
// Return false if themes not activated
bool DrawThemeBackgroundPart(HWND hwnd,LPCWSTR pszClassList,HDC hdc,int iPartId,int iStateId,const RECT *pRect,const RECT *pClipRect);
// DP: 21/05/2004 Added this function copied from Davide Calabro to permit use in CXPStyleButtonST
HRESULT DrawThemeBackground(HTHEME hTheme,HWND hWnd,HDC hdc,int iPartId,int iStateId, RECT* pRect,const RECT* pClipRect);
// DP: 24/05/2004 Added this function as the definitive, yes-or-no, do-I-or-don't-I, are-we-using-themes-or-not function
// It's required because IsAppThemed does not, as its cunningly disguised name might imply, tell you whether the app is themed
bool IsAppUsingThemes();
// DP: 11/12/2008: we now don't check every time, so separate actual check from "get" function
bool CheckIfAppIsUsingThemes();
// DP: 24/05/2004 Nicked this from MFC and modified it (MFC doesn't export it)
DWORD GetComCtl32Version();
private:
// DP 21/05/2004: Added to make into singleton
static CVisualStylesXP *m_pVisualStylesXP;
// DP: 24/05/2004 Added to store ComCtl version number
DWORD m_nComCtl32Version;
private:
HMODULE m_hThemeDll;
void* GetProc(LPCSTR szProc, void* pfnFail);
typedef HTHEME(__stdcall *PFNOPENTHEMEDATA)(HWND hwnd, LPCWSTR pszClassList);
// static HTHEME OpenThemeDataFail(HWND , LPCWSTR )
// DP: 04/11/2003 Applied fix from swinefeaster
static HTHEME __stdcall OpenThemeDataFail(HWND , LPCWSTR )
{return NULL;}
typedef HRESULT(__stdcall *PFNCLOSETHEMEDATA)(HTHEME hTheme);
static HRESULT CloseThemeDataFail(HTHEME)
{return E_FAIL;}
typedef HRESULT(__stdcall *PFNDRAWTHEMEBACKGROUND)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect);
static HRESULT DrawThemeBackgroundFail(HTHEME, HDC, int, int, const RECT *, const RECT *)
{return E_FAIL;}
// DP 24/6/2004: Added this function
typedef HRESULT(__stdcall *PFNDRAWTHEMEBACKGROUNDEX)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, const DTBGOPTS * pOptions);
static HRESULT DrawThemeBackgroundExFail(HTHEME, HDC, int, int, const RECT *, const DTBGOPTS *)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNDRAWTHEMETEXT)(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags,
DWORD dwTextFlags2, const RECT *pRect);
static HRESULT DrawThemeTextFail(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, DWORD, const RECT*)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEBACKGROUNDCONTENTRECT)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pBoundingRect,
RECT *pContentRect);
static HRESULT GetThemeBackgroundContentRectFail(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pBoundingRect,
RECT *pContentRect)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEBACKGROUNDEXTENT)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pContentRect,
RECT *pExtentRect);
static HRESULT GetThemeBackgroundExtentFail(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pContentRect,
RECT *pExtentRect)
{return E_FAIL;}
typedef HRESULT(__stdcall *PFNGETTHEMEPARTSIZE)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, RECT * pRect, enum THEMESIZE eSize, SIZE *psz);
static HRESULT GetThemePartSizeFail(HTHEME, HDC, int, int, RECT *, enum THEMESIZE, SIZE *)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMETEXTEXTENT)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, LPCWSTR pszText, int iCharCount,
DWORD dwTextFlags, const RECT *pBoundingRect,
RECT *pExtentRect);
static HRESULT GetThemeTextExtentFail(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, LPCWSTR pszText, int iCharCount,
DWORD dwTextFlags, const RECT *pBoundingRect,
RECT *pExtentRect)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMETEXTMETRICS)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, TEXTMETRIC* ptm);
static HRESULT GetThemeTextMetricsFail(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, TEXTMETRIC* ptm)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEBACKGROUNDREGION)(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, HRGN *pRegion);
static HRESULT GetThemeBackgroundRegionFail(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, HRGN *pRegion)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNHITTESTTHEMEBACKGROUND)(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, DWORD dwOptions, const RECT *pRect, HRGN hrgn,
POINT ptTest, WORD *pwHitTestCode);
static HRESULT HitTestThemeBackgroundFail(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, DWORD dwOptions, const RECT *pRect, HRGN hrgn,
POINT ptTest, WORD *pwHitTestCode)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNDRAWTHEMEEDGE)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect);
static HRESULT DrawThemeEdgeFail(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNDRAWTHEMEICON)(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex);
static HRESULT DrawThemeIconFail(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex)
{return E_FAIL;}
typedef BOOL (__stdcall *PFNISTHEMEPARTDEFINED)(HTHEME hTheme, int iPartId,
int iStateId);
static BOOL IsThemePartDefinedFail(HTHEME hTheme, int iPartId,
int iStateId)
{return FALSE;}
typedef BOOL (__stdcall *PFNISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)(HTHEME hTheme,
int iPartId, int iStateId);
static BOOL IsThemeBackgroundPartiallyTransparentFail(HTHEME hTheme,
int iPartId, int iStateId)
{return FALSE;}
typedef HRESULT (__stdcall *PFNGETTHEMECOLOR)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, COLORREF *pColor);
static HRESULT GetThemeColorFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, COLORREF *pColor)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEMETRIC)(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, int *piVal);
static HRESULT GetThemeMetricFail(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, int *piVal)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMESTRING)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszBuff, int cchMaxBuffChars);
static HRESULT GetThemeStringFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEBOOL)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, BOOL *pfVal);
static HRESULT GetThemeBoolFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, BOOL *pfVal)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEINT)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal);
static HRESULT GetThemeIntFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEENUMVALUE)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal);
static HRESULT GetThemeEnumValueFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEPOSITION)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, POINT *pPoint);
static HRESULT GetThemePositionFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, POINT *pPoint)
{return E_FAIL;}
// DP 13/03/2007: Function actually takes a LOGFONTW, not a LOGFONT as the documentation misleadingly
// suggests
typedef HRESULT (__stdcall *PFNGETTHEMEFONT)(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, LOGFONTW *pFont);
static HRESULT GetThemeFontFail(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, LOGFONTW *pFont)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMERECT)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, RECT *pRect);
static HRESULT GetThemeRectFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, RECT *pRect)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEMARGINS)(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, RECT *prc, MARGINS *pMargins);
static HRESULT GetThemeMarginsFail(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEINTLIST)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, INTLIST *pIntList);
static HRESULT GetThemeIntListFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, INTLIST *pIntList)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEPROPERTYORIGIN)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, enum PROPERTYORIGIN *pOrigin);
static HRESULT GetThemePropertyOriginFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, enum PROPERTYORIGIN *pOrigin)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNSETWINDOWTHEME)(HWND hwnd, LPCWSTR pszSubAppName,
LPCWSTR pszSubIdList);
static HRESULT SetWindowThemeFail(HWND hwnd, LPCWSTR pszSubAppName,
LPCWSTR pszSubIdList)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEFILENAME)(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszThemeFileName, int cchMaxBuffChars);
static HRESULT GetThemeFilenameFail(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszThemeFileName, int cchMaxBuffChars)
{return E_FAIL;}
typedef COLORREF (__stdcall *PFNGETTHEMESYSCOLOR)(HTHEME hTheme, int iColorId);
static COLORREF GetThemeSysColorFail(HTHEME hTheme, int iColorId)
{return RGB(255,255,255);}
typedef HBRUSH (__stdcall *PFNGETTHEMESYSCOLORBRUSH)(HTHEME hTheme, int iColorId);
static HBRUSH GetThemeSysColorBrushFail(HTHEME hTheme, int iColorId)
{return NULL;}
typedef BOOL (__stdcall *PFNGETTHEMESYSBOOL)(HTHEME hTheme, int iBoolId);
static BOOL GetThemeSysBoolFail(HTHEME hTheme, int iBoolId)
{return FALSE;}
typedef int (__stdcall *PFNGETTHEMESYSSIZE)(HTHEME hTheme, int iSizeId);
static int GetThemeSysSizeFail(HTHEME hTheme, int iSizeId)
{return 0;}
// DP 13/03/2007: Function actually returns a LOGFONTW, not a LOGFONT as the documentation misleadingly
// suggests
typedef HRESULT (__stdcall *PFNGETTHEMESYSFONT)(HTHEME hTheme, int iFontId, LOGFONTW *plf);
static HRESULT GetThemeSysFontFail(HTHEME hTheme, int iFontId, LOGFONTW *plf)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMESYSSTRING)(HTHEME hTheme, int iStringId,
LPWSTR pszStringBuff, int cchMaxStringChars);
static HRESULT GetThemeSysStringFail(HTHEME hTheme, int iStringId,
LPWSTR pszStringBuff, int cchMaxStringChars)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMESYSINT)(HTHEME hTheme, int iIntId, int *piValue);
static HRESULT GetThemeSysIntFail(HTHEME hTheme, int iIntId, int *piValue)
{return E_FAIL;}
typedef BOOL (__stdcall *PFNISTHEMEACTIVE)();
static BOOL IsThemeActiveFail()
{return FALSE;}
typedef BOOL(__stdcall *PFNISAPPTHEMED)();
static BOOL IsAppThemedFail()
{return FALSE;}
typedef HTHEME (__stdcall *PFNGETWINDOWTHEME)(HWND hwnd);
static HTHEME GetWindowThemeFail(HWND hwnd)
{return NULL;}
typedef HRESULT (__stdcall *PFNENABLETHEMEDIALOGTEXTURE)(HWND hwnd, DWORD dwFlags);
static HRESULT EnableThemeDialogTextureFail(HWND hwnd, DWORD dwFlags)
{return E_FAIL;}
typedef BOOL (__stdcall *PFNISTHEMEDIALOGTEXTUREENABLED)(HWND hwnd);
static BOOL IsThemeDialogTextureEnabledFail(HWND hwnd)
{return FALSE;}
typedef DWORD (__stdcall *PFNGETTHEMEAPPPROPERTIES)();
static DWORD GetThemeAppPropertiesFail()
{return 0;}
typedef void (__stdcall *PFNSETTHEMEAPPPROPERTIES)(DWORD dwFlags);
static void SetThemeAppPropertiesFail(DWORD dwFlags)
{return;}
typedef HRESULT (__stdcall *PFNGETCURRENTTHEMENAME)(
LPWSTR pszThemeFileName, int cchMaxNameChars,
LPWSTR pszColorBuff, int cchMaxColorChars,
LPWSTR pszSizeBuff, int cchMaxSizeChars);
static HRESULT GetCurrentThemeNameFail(
LPWSTR pszThemeFileName, int cchMaxNameChars,
LPWSTR pszColorBuff, int cchMaxColorChars,
LPWSTR pszSizeBuff, int cchMaxSizeChars)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNGETTHEMEDOCUMENTATIONPROPERTY)(LPCWSTR pszThemeName,
LPCWSTR pszPropertyName, LPWSTR pszValueBuff, int cchMaxValChars);
static HRESULT GetThemeDocumentationPropertyFail(LPCWSTR pszThemeName,
LPCWSTR pszPropertyName, LPWSTR pszValueBuff, int cchMaxValChars)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNDRAWTHEMEPARENTBACKGROUND)(HWND hwnd, HDC hdc, RECT* prc);
static HRESULT DrawThemeParentBackgroundFail(HWND hwnd, HDC hdc, RECT* prc)
{return E_FAIL;}
typedef HRESULT (__stdcall *PFNENABLETHEMING)(BOOL fEnable);
static HRESULT EnableThemingFail(BOOL fEnable)
{return E_FAIL;}
public:
HTHEME OpenThemeData(HWND hwnd, LPCWSTR pszClassList);
HRESULT CloseThemeData(HTHEME hTheme);
HRESULT DrawThemeBackground(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect);
HRESULT DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags,
DWORD dwTextFlags2, const RECT *pRect);
HRESULT GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pBoundingRect,
RECT *pContentRect);
HRESULT GetThemeBackgroundExtent(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pContentRect,
RECT *pExtentRect);
HRESULT GetThemePartSize(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, RECT * pRect, enum THEMESIZE eSize, SIZE *psz);
HRESULT GetThemeTextExtent(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, LPCWSTR pszText, int iCharCount,
DWORD dwTextFlags, const RECT *pBoundingRect,
RECT *pExtentRect);
HRESULT GetThemeTextMetrics(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, TEXTMETRIC* ptm);
HRESULT GetThemeBackgroundRegion(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, HRGN *pRegion);
HRESULT HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, DWORD dwOptions, const RECT *pRect, HRGN hrgn,
POINT ptTest, WORD *pwHitTestCode);
HRESULT DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect);
HRESULT DrawThemeIcon(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex);
BOOL IsThemePartDefined(HTHEME hTheme, int iPartId,
int iStateId);
BOOL IsThemeBackgroundPartiallyTransparent(HTHEME hTheme,
int iPartId, int iStateId);
HRESULT GetThemeColor(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, COLORREF *pColor);
HRESULT GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, int *piVal);
HRESULT GetThemeString(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszBuff, int cchMaxBuffChars);
HRESULT GetThemeBool(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, BOOL *pfVal);
HRESULT GetThemeInt(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal);
HRESULT GetThemeEnumValue(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal);
HRESULT GetThemePosition(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, POINT *pPoint);
// DP 13/03/2007: Function actually takes a LOGFONTW, not a LOGFONT as the documentation misleadingly
// suggests
HRESULT GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, LOGFONTW *pFont);
HRESULT GetThemeRect(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, RECT *pRect);
HRESULT GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, RECT *prc, MARGINS *pMargins);
HRESULT GetThemeIntList(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, INTLIST *pIntList);
HRESULT GetThemePropertyOrigin(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, enum PROPERTYORIGIN *pOrigin);
HRESULT SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
LPCWSTR pszSubIdList);
HRESULT GetThemeFilename(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszThemeFileName, int cchMaxBuffChars);
COLORREF GetThemeSysColor(HTHEME hTheme, int iColorId);
HBRUSH GetThemeSysColorBrush(HTHEME hTheme, int iColorId);
BOOL GetThemeSysBool(HTHEME hTheme, int iBoolId);
int GetThemeSysSize(HTHEME hTheme, int iSizeId);
// DP 13/03/2007: Function actually returns a LOGFONTW, not a LOGFONT as the documentation misleadingly
// suggests
HRESULT GetThemeSysFont(HTHEME hTheme, int iFontId, LOGFONTW *plf);
HRESULT GetThemeSysString(HTHEME hTheme, int iStringId,
LPWSTR pszStringBuff, int cchMaxStringChars);
HRESULT GetThemeSysInt(HTHEME hTheme, int iIntId, int *piValue);
BOOL IsThemeActive();
BOOL IsAppThemed();
HTHEME GetWindowTheme(HWND hwnd);
HRESULT EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags);
BOOL IsThemeDialogTextureEnabled(HWND hwnd);
DWORD GetThemeAppProperties();
void SetThemeAppProperties(DWORD dwFlags);
HRESULT GetCurrentThemeName(
LPWSTR pszThemeFileName, int cchMaxNameChars,
LPWSTR pszColorBuff, int cchMaxColorChars,
LPWSTR pszSizeBuff, int cchMaxSizeChars);
HRESULT GetThemeDocumentationProperty(LPCWSTR pszThemeName,
LPCWSTR pszPropertyName, LPWSTR pszValueBuff, int cchMaxValChars);
HRESULT DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT* prc);
// DP 24/6/2005 Added this function
HRESULT DrawThemeBackgroundEx(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const DTBGOPTS *pOptions);
HRESULT EnableTheming(BOOL fEnable);
public:
CVisualStylesXP(void);
~CVisualStylesXP(void);
};
// DP 24/09/2004: Reenable warnings for compiling at level 4
#pragma warning( default : 4100)
//extern CVisualStylesXP g_xpStyle;
#endif
-----------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2002 by David Yuheng Zhao
//
// Distribute and change freely, except: don't remove my name from the source
//
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Partly based on the _ThemeHelper struct in MFC7.0 source code (winctrl3.cpp),
// and the difference is that this implementation wraps the full set of
// visual style APIs from the platform SDK August 2001
//
// If you have any questions, I can be reached as follows:
// yuheng_zhao@yahoo.com
//
//
// How to use:
// Instead of calling the API directly,
// OpenThemeData(...);
// use the global variable
// g_xpStyle.OpenThemeData(...);
//
// DP 21/05/2004: Modified to make into singleton and export
//
/////////////////////////////////////////////////////////////////////////////
#include "stdAfx.h"
#include "..\stdafx.h" // Repeat include for the benefit of idiot dumbed-down Intellisense in VS2005+
#include "visualstylesxp.h"
// DP 21/05/2004: Modified to make into singleton and export
//CVisualStylesXP g_xpStyle;
CVisualStylesXP *CVisualStylesXP::m_pVisualStylesXP = NULL;
CVisualStylesXP * CVisualStylesXP::GetInstance ()
{
if (!m_pVisualStylesXP)
{
m_pVisualStylesXP = new CVisualStylesXP;
}
return m_pVisualStylesXP;
}
// Deletes the instance of the singleton.
void CVisualStylesXP::DeleteInstance ()
{
if (m_pVisualStylesXP)
{
delete m_pVisualStylesXP;
m_pVisualStylesXP = NULL;
}
}
CVisualStylesXP::CVisualStylesXP(void)
{
// For UNICODE/Win2k+ only: avoid horrible "Unable to locate component" error messages in Vista when dependent DLLs of
// dynamically-loaded DLLs are not found.
CWindowsErrorModeSwitcher switcherErrorMode(SEM_FAILCRITICALERRORS);
m_hThemeDll = LoadLibrary(_T("UxTheme.dll"));
// Initialise version
m_nComCtl32Version = (DWORD)-1;
}
CVisualStylesXP::~CVisualStylesXP(void)
{
if (m_hThemeDll!=NULL)
FreeLibrary(m_hThemeDll);
m_hThemeDll = NULL;
}
void* CVisualStylesXP::GetProc(LPCSTR szProc, void* pfnFail)
{
void* pRet = pfnFail;
if (m_hThemeDll != NULL)
pRet = GetProcAddress(m_hThemeDll, szProc);
return pRet;
}
HTHEME CVisualStylesXP::OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
{
PFNOPENTHEMEDATA pfnOpenThemeData = (PFNOPENTHEMEDATA)GetProc("OpenThemeData", (void*)OpenThemeDataFail);
return (*pfnOpenThemeData)(hwnd, pszClassList);
}
HRESULT CVisualStylesXP::CloseThemeData(HTHEME hTheme)
{
PFNCLOSETHEMEDATA pfnCloseThemeData = (PFNCLOSETHEMEDATA)GetProc("CloseThemeData", (void*)CloseThemeDataFail);
return (*pfnCloseThemeData)(hTheme);
}
HRESULT CVisualStylesXP::DrawThemeBackground(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
{
PFNDRAWTHEMEBACKGROUND pfnDrawThemeBackground =
(PFNDRAWTHEMEBACKGROUND)GetProc("DrawThemeBackground", (void*)DrawThemeBackgroundFail);
return (*pfnDrawThemeBackground)(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
}
// DP 24/6/2005 Added this function
HRESULT CVisualStylesXP::DrawThemeBackgroundEx(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, const DTBGOPTS *pOptions)
{
PFNDRAWTHEMEBACKGROUNDEX pfnDrawThemeBackgroundEx =
(PFNDRAWTHEMEBACKGROUNDEX)GetProc("DrawThemeBackgroundEx", (void*)DrawThemeBackgroundExFail);
return (*pfnDrawThemeBackgroundEx)(hTheme, hdc, iPartId, iStateId, pRect, pOptions);
}
// DP: 16/07/2004 Added this function to wrap the whole process in one function
// Return false if themes not activated
bool CVisualStylesXP::DrawThemeBackgroundPart(HWND hwnd, LPCWSTR pszClassList, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
{
if (CVisualStylesXP::GetInstance()->IsAppUsingThemes())
{
// Open data
CTempThemeHandle tempHandle(hwnd, pszClassList);
//HTHEME hTheme = CVisualStylesXP::GetInstance()->OpenThemeData(hwnd, pszClassList);
// Draw the background
VERIFY( CVisualStylesXP::GetInstance()->DrawThemeBackground(tempHandle.GetThemeHandle(), hdc, iPartId, iStateId, pRect, pClipRect) == S_OK);
// Clean up
//CVisualStylesXP::GetInstance()->CloseThemeData(hTheme);
return true;
}
else
{
return false;
}
}
// DP: 21/05/2004 Added this function copied from Davide Calabro to permit use in CXPStyleButtonST
HRESULT CVisualStylesXP::DrawThemeBackground(HTHEME hTheme, HWND hWnd, HDC hdc, int iPartId, int iStateId, RECT* pRect, const RECT* pClipRect)
{
// First draw parent background
DrawThemeParentBackground(hWnd, hdc, pRect);
// Then draw theme background
return DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
} // End of DrawThemeBackground
// DP: 24/05/2004 Added this function as the definitive, yes-or-no, do-I-or-don't-I, are-we-using-themes-or-not function
// It's required because IsAppThemed does not, in spite of what its cunningly disguised name might imply,
// tell you whether the app is themed
bool CVisualStylesXP::IsAppUsingThemes()
{
// DP 11/12/2008: For some reason, the themes engine doesn't seem to wake up immediately, so the first few checks on
// theming may return "false" from IsAppThemed. To avoid this becoming the definitive answer for the rest of the
// session, check 20 times and then return the static value.
static int nCheckCounter = 0;
static bool bIsUsingThemes = false;
if (nCheckCounter < 20)
{
bIsUsingThemes = CheckIfAppIsUsingThemes();
nCheckCounter++;
}
// Only calculate this once to save time!
return bIsUsingThemes;
// return (GetComCtl32Version() >= nCOMCTL_VERSION_XP && IsThemeActive() && IsAppThemed());
}
// DP: 11/12/2008: we now don't check every time, so separate actual check from "get" function
bool CVisualStylesXP::CheckIfAppIsUsingThemes()
{
// If we have the correct COMCTL32 version AND IsAppThemed AND IsThemeActive return true, then true
return (GetComCtl32Version() >= nCOMCTL_VERSION_XP && IsThemeActive() && IsAppThemed());
}
// DP: 24/05/2004 Nicked this from MFC and modified it (MFC doesn't export it)
struct AFX_DLLVERSIONINFO
{
DWORD cbSize;
DWORD dwMajorVersion; // Major version
DWORD dwMinorVersion; // Minor version
DWORD dwBuildNumber; // Build number
DWORD dwPlatformID; // DLLVER_PLATFORM_*
};
typedef HRESULT (CALLBACK* AFX_DLLGETVERSIONPROC)(AFX_DLLVERSIONINFO *);
DWORD CVisualStylesXP::GetComCtl32Version()
{
// If we haven't obtained the version...
if (m_nComCtl32Version == -1)
{
// otherwise determine comctl32.dll version via DllGetVersion
HINSTANCE hInst = ::GetModuleHandle(sCOMCTL32_DLLNAME);
ASSERT(hInst != NULL);
if (hInst != NULL)
{
AFX_DLLGETVERSIONPROC pfn;
pfn = (AFX_DLLGETVERSIONPROC)GetProcAddress(hInst, "DllGetVersion");
DWORD dwVersion = nCOMCTL_VERSION_WIN4;
if (pfn != NULL)
{
AFX_DLLVERSIONINFO dvi;
memset(&dvi, 0, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
HRESULT hr = (*pfn)(&dvi);
if (SUCCEEDED(hr))
{
ASSERT(dvi.dwMajorVersion <= 0xFFFF);
ASSERT(dvi.dwMinorVersion <= 0xFFFF);
dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
}
}
// Store in member variable
m_nComCtl32Version = dwVersion;
}
}
// Return member
return m_nComCtl32Version;
}
HRESULT CVisualStylesXP::DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags,
DWORD dwTextFlags2, const RECT *pRect)
{
PFNDRAWTHEMETEXT pfn = (PFNDRAWTHEMETEXT)GetProc("DrawThemeText", (void*)DrawThemeTextFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, dwTextFlags2, pRect);
}
HRESULT CVisualStylesXP::GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pBoundingRect,
RECT *pContentRect)
{
PFNGETTHEMEBACKGROUNDCONTENTRECT pfn = (PFNGETTHEMEBACKGROUNDCONTENTRECT)GetProc("GetThemeBackgroundContentRect", (void*)GetThemeBackgroundContentRectFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, pBoundingRect, pContentRect);
}
HRESULT CVisualStylesXP::GetThemeBackgroundExtent(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pContentRect,
RECT *pExtentRect)
{
PFNGETTHEMEBACKGROUNDEXTENT pfn = (PFNGETTHEMEBACKGROUNDEXTENT)GetProc("GetThemeBackgroundExtent", (void*)GetThemeBackgroundExtentFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, pContentRect, pExtentRect);
}
HRESULT CVisualStylesXP::GetThemePartSize(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, RECT * pRect, enum THEMESIZE eSize, SIZE *psz)
{
PFNGETTHEMEPARTSIZE pfnGetThemePartSize =
(PFNGETTHEMEPARTSIZE)GetProc("GetThemePartSize", (void*)GetThemePartSizeFail);
return (*pfnGetThemePartSize)(hTheme, hdc, iPartId, iStateId, pRect, eSize, psz);
}
HRESULT CVisualStylesXP::GetThemeTextExtent(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, LPCWSTR pszText, int iCharCount,
DWORD dwTextFlags, const RECT *pBoundingRect,
RECT *pExtentRect)
{
PFNGETTHEMETEXTEXTENT pfn = (PFNGETTHEMETEXTEXTENT)GetProc("GetThemeTextExtent", (void*)GetThemeTextExtentFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, pBoundingRect, pExtentRect);
}
HRESULT CVisualStylesXP::GetThemeTextMetrics(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, TEXTMETRIC* ptm)
{
PFNGETTHEMETEXTMETRICS pfn = (PFNGETTHEMETEXTMETRICS)GetProc("GetThemeTextMetrics", (void*)GetThemeTextMetricsFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, ptm);
}
HRESULT CVisualStylesXP::GetThemeBackgroundRegion(HTHEME hTheme, HDC hdc,
int iPartId, int iStateId, const RECT *pRect, HRGN *pRegion)
{
PFNGETTHEMEBACKGROUNDREGION pfn = (PFNGETTHEMEBACKGROUNDREGION)GetProc("GetThemeBackgroundRegion", (void*)GetThemeBackgroundRegionFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, pRect, pRegion);
}
HRESULT CVisualStylesXP::HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, DWORD dwOptions, const RECT *pRect, HRGN hrgn,
POINT ptTest, WORD *pwHitTestCode)
{
PFNHITTESTTHEMEBACKGROUND pfn = (PFNHITTESTTHEMEBACKGROUND)GetProc("HitTestThemeBackground", (void*)HitTestThemeBackgroundFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, dwOptions, pRect, hrgn, ptTest, pwHitTestCode);
}
HRESULT CVisualStylesXP::DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect)
{
PFNDRAWTHEMEEDGE pfn = (PFNDRAWTHEMEEDGE)GetProc("DrawThemeEdge", (void*)DrawThemeEdgeFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, pDestRect, uEdge, uFlags, pContentRect);
}
HRESULT CVisualStylesXP::DrawThemeIcon(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex)
{
PFNDRAWTHEMEICON pfn = (PFNDRAWTHEMEICON)GetProc("DrawThemeIcon", (void*)DrawThemeIconFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex);
}
BOOL CVisualStylesXP::IsThemePartDefined(HTHEME hTheme, int iPartId,
int iStateId)
{
PFNISTHEMEPARTDEFINED pfn = (PFNISTHEMEPARTDEFINED)GetProc("IsThemePartDefined", (void*)IsThemePartDefinedFail);
return (*pfn)(hTheme, iPartId, iStateId);
}
BOOL CVisualStylesXP::IsThemeBackgroundPartiallyTransparent(HTHEME hTheme,
int iPartId, int iStateId)
{
PFNISTHEMEBACKGROUNDPARTIALLYTRANSPARENT pfn = (PFNISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)GetProc("IsThemeBackgroundPartiallyTransparent", (void*)IsThemeBackgroundPartiallyTransparentFail);
return (*pfn)(hTheme, iPartId, iStateId);
}
HRESULT CVisualStylesXP::GetThemeColor(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, COLORREF *pColor)
{
PFNGETTHEMECOLOR pfn = (PFNGETTHEMECOLOR)GetProc("GetThemeColor", (void*)GetThemeColorFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pColor);
}
HRESULT CVisualStylesXP::GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, int *piVal)
{
PFNGETTHEMEMETRIC pfn = (PFNGETTHEMEMETRIC)GetProc("GetThemeMetric", (void*)GetThemeMetricFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, iPropId, piVal);
}
HRESULT CVisualStylesXP::GetThemeString(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
{
PFNGETTHEMESTRING pfn = (PFNGETTHEMESTRING)GetProc("GetThemeString", (void*)GetThemeStringFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pszBuff, cchMaxBuffChars);
}
HRESULT CVisualStylesXP::GetThemeBool(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, BOOL *pfVal)
{
PFNGETTHEMEBOOL pfn = (PFNGETTHEMEBOOL)GetProc("GetThemeBool", (void*)GetThemeBoolFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pfVal);
}
HRESULT CVisualStylesXP::GetThemeInt(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal)
{
PFNGETTHEMEINT pfn = (PFNGETTHEMEINT)GetProc("GetThemeInt", (void*)GetThemeIntFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, piVal);
}
HRESULT CVisualStylesXP::GetThemeEnumValue(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, int *piVal)
{
PFNGETTHEMEENUMVALUE pfn = (PFNGETTHEMEENUMVALUE)GetProc("GetThemeEnumValue", (void*)GetThemeEnumValueFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, piVal);
}
HRESULT CVisualStylesXP::GetThemePosition(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, POINT *pPoint)
{
PFNGETTHEMEPOSITION pfn = (PFNGETTHEMEPOSITION)GetProc("GetThemePosition", (void*)GetThemePositionFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pPoint);
}
// DP 13/03/2007: Function actually takes a LOGFONTW, not a LOGFONT as the documentation misleadingly
// suggests
HRESULT CVisualStylesXP::GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, LOGFONTW *pFont)
{
PFNGETTHEMEFONT pfn = (PFNGETTHEMEFONT)GetProc("GetThemeFont", (void*)GetThemeFontFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, iPropId, pFont);
}
HRESULT CVisualStylesXP::GetThemeRect(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, RECT *pRect)
{
PFNGETTHEMERECT pfn = (PFNGETTHEMERECT)GetProc("GetThemeRect", (void*)GetThemeRectFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pRect);
}
HRESULT CVisualStylesXP::GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
{
PFNGETTHEMEMARGINS pfn = (PFNGETTHEMEMARGINS)GetProc("GetThemeMargins", (void*)GetThemeMarginsFail);
return (*pfn)(hTheme, hdc, iPartId, iStateId, iPropId, prc, pMargins);
}
HRESULT CVisualStylesXP::GetThemeIntList(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, INTLIST *pIntList)
{
PFNGETTHEMEINTLIST pfn = (PFNGETTHEMEINTLIST)GetProc("GetThemeIntList", (void*)GetThemeIntListFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pIntList);
}
HRESULT CVisualStylesXP::GetThemePropertyOrigin(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, enum PROPERTYORIGIN *pOrigin)
{
PFNGETTHEMEPROPERTYORIGIN pfn = (PFNGETTHEMEPROPERTYORIGIN)GetProc("GetThemePropertyOrigin", (void*)GetThemePropertyOriginFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pOrigin);
}
HRESULT CVisualStylesXP::SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
LPCWSTR pszSubIdList)
{
PFNSETWINDOWTHEME pfn = (PFNSETWINDOWTHEME)GetProc("SetWindowTheme", (void*)SetWindowThemeFail);
return (*pfn)(hwnd, pszSubAppName, pszSubIdList);
}
HRESULT CVisualStylesXP::GetThemeFilename(HTHEME hTheme, int iPartId,
int iStateId, int iPropId, LPWSTR pszThemeFileName, int cchMaxBuffChars)
{
PFNGETTHEMEFILENAME pfn = (PFNGETTHEMEFILENAME)GetProc("GetThemeFilename", (void*)GetThemeFilenameFail);
return (*pfn)(hTheme, iPartId, iStateId, iPropId, pszThemeFileName, cchMaxBuffChars);
}
COLORREF CVisualStylesXP::GetThemeSysColor(HTHEME hTheme, int iColorId)
{
PFNGETTHEMESYSCOLOR pfn = (PFNGETTHEMESYSCOLOR)GetProc("GetThemeSysColor", (void*)GetThemeSysColorFail);
return (*pfn)(hTheme, iColorId);
}
HBRUSH CVisualStylesXP::GetThemeSysColorBrush(HTHEME hTheme, int iColorId)
{
PFNGETTHEMESYSCOLORBRUSH pfn = (PFNGETTHEMESYSCOLORBRUSH)GetProc("GetThemeSysColorBrush", (void*)GetThemeSysColorBrushFail);
return (*pfn)(hTheme, iColorId);
}
BOOL CVisualStylesXP::GetThemeSysBool(HTHEME hTheme, int iBoolId)
{
PFNGETTHEMESYSBOOL pfn = (PFNGETTHEMESYSBOOL)GetProc("GetThemeSysBool", (void*)GetThemeSysBoolFail);
return (*pfn)(hTheme, iBoolId);
}
int CVisualStylesXP::GetThemeSysSize(HTHEME hTheme, int iSizeId)
{
PFNGETTHEMESYSSIZE pfn = (PFNGETTHEMESYSSIZE)GetProc("GetThemeSysSize", (void*)GetThemeSysSizeFail);
return (*pfn)(hTheme, iSizeId);
}
// DP 13/03/2007: Function actually returns a LOGFONTW, not a LOGFONT as the documentation misleadingly
// suggests
HRESULT CVisualStylesXP::GetThemeSysFont(HTHEME hTheme, int iFontId, LOGFONTW *plf)
{
PFNGETTHEMESYSFONT pfn = (PFNGETTHEMESYSFONT)GetProc("GetThemeSysFont", (void*)GetThemeSysFontFail);
return (*pfn)(hTheme, iFontId, plf);
}
HRESULT CVisualStylesXP::GetThemeSysString(HTHEME hTheme, int iStringId,
LPWSTR pszStringBuff, int cchMaxStringChars)
{
PFNGETTHEMESYSSTRING pfn = (PFNGETTHEMESYSSTRING)GetProc("GetThemeSysString", (void*)GetThemeSysStringFail);
return (*pfn)(hTheme, iStringId, pszStringBuff, cchMaxStringChars);
}
HRESULT CVisualStylesXP::GetThemeSysInt(HTHEME hTheme, int iIntId, int *piValue)
{
PFNGETTHEMESYSINT pfn = (PFNGETTHEMESYSINT)GetProc("GetThemeSysInt", (void*)GetThemeSysIntFail);
return (*pfn)(hTheme, iIntId, piValue);
}
BOOL CVisualStylesXP::IsThemeActive()
{
PFNISTHEMEACTIVE pfn = (PFNISTHEMEACTIVE)GetProc("IsThemeActive", (void*)IsThemeActiveFail);
return (*pfn)();
}
BOOL CVisualStylesXP::IsAppThemed()
{
PFNISAPPTHEMED pfnIsAppThemed = (PFNISAPPTHEMED)GetProc("IsAppThemed", (void*)IsAppThemedFail);
return (*pfnIsAppThemed)();
}
HTHEME CVisualStylesXP::GetWindowTheme(HWND hwnd)
{
PFNGETWINDOWTHEME pfn = (PFNGETWINDOWTHEME)GetProc("GetWindowTheme", (void*)GetWindowThemeFail);
return (*pfn)(hwnd);
}
HRESULT CVisualStylesXP::EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags)
{
PFNENABLETHEMEDIALOGTEXTURE pfn = (PFNENABLETHEMEDIALOGTEXTURE)GetProc("EnableThemeDialogTexture", (void*)EnableThemeDialogTextureFail);
return (*pfn)(hwnd, dwFlags);
}
BOOL CVisualStylesXP::IsThemeDialogTextureEnabled(HWND hwnd)
{
PFNISTHEMEDIALOGTEXTUREENABLED pfn = (PFNISTHEMEDIALOGTEXTUREENABLED)GetProc("IsThemeDialogTextureEnabled", (void*)IsThemeDialogTextureEnabledFail);
return (*pfn)(hwnd);
}
DWORD CVisualStylesXP::GetThemeAppProperties()
{
PFNGETTHEMEAPPPROPERTIES pfn = (PFNGETTHEMEAPPPROPERTIES)GetProc("GetThemeAppProperties", (void*)GetThemeAppPropertiesFail);
return (*pfn)();
}
void CVisualStylesXP::SetThemeAppProperties(DWORD dwFlags)
{
PFNSETTHEMEAPPPROPERTIES pfn = (PFNSETTHEMEAPPPROPERTIES)GetProc("SetThemeAppProperties", (void*)SetThemeAppPropertiesFail);
(*pfn)(dwFlags);
}
HRESULT CVisualStylesXP::GetCurrentThemeName(
LPWSTR pszThemeFileName, int cchMaxNameChars,
LPWSTR pszColorBuff, int cchMaxColorChars,
LPWSTR pszSizeBuff, int cchMaxSizeChars)
{
PFNGETCURRENTTHEMENAME pfn = (PFNGETCURRENTTHEMENAME)GetProc("GetCurrentThemeName", (void*)GetCurrentThemeNameFail);
return (*pfn)(pszThemeFileName, cchMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars);
}
HRESULT CVisualStylesXP::GetThemeDocumentationProperty(LPCWSTR pszThemeName,
LPCWSTR pszPropertyName, LPWSTR pszValueBuff, int cchMaxValChars)
{
PFNGETTHEMEDOCUMENTATIONPROPERTY pfn = (PFNGETTHEMEDOCUMENTATIONPROPERTY)GetProc("GetThemeDocumentationProperty", (void*)GetThemeDocumentationPropertyFail);
return (*pfn)(pszThemeName, pszPropertyName, pszValueBuff, cchMaxValChars);
}
HRESULT CVisualStylesXP::DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT* prc)
{
PFNDRAWTHEMEPARENTBACKGROUND pfn = (PFNDRAWTHEMEPARENTBACKGROUND)GetProc("DrawThemeParentBackground", (void*)DrawThemeParentBackgroundFail);
return (*pfn)(hwnd, hdc, prc);
}
HRESULT CVisualStylesXP::EnableTheming(BOOL fEnable)
{
PFNENABLETHEMING pfn = (PFNENABLETHEMING)GetProc("EnableTheming", (void*)EnableThemingFail);
return (*pfn)(fEnable);
}
- Pfft. Coddled kids. In my day, we used to telnet to port 80, then render the page with pencil and paper-- and that's the way we liked it!
- Pshaw! Youngster. Your UID barely fits inside 16 bits. In _my_ day we had to whistle the 1's and 0's through an acoustic coupler!
Tools that support "all of UTF-8 as long as it starts with ASCII" and tools that cannot handle these three [BOM] bytes at all are not really supporting UTF-8.
- Michael Kaplan
modified on Wednesday, August 3, 2011 4:55 AM
|