bool UGXPThemes::GetThemeRect(LPCWSTR theme, int iPartId, int iStateId, RECT *pRect) { bool success = false; if (useThemes) { HANDLE themeHandle = OpenThemeData(NULL, theme); if (themeHandle) { //const int TMT_DEFAULTPANESIZE = 5002; //HRESULT hr = GetThemeRect(themeHandle, iPartId, iStateId, TMT_DEFAULTPANESIZE, pRect); HRESULT hr = GetThemeRect(themeHandle, iPartId, iStateId, 5002, pRect); success = SUCCEEDED(hr); } } return success; }
BOOL CXTPSkinManagerClass::DrawThemeText(CDC* pDC, int iPartId, int iStateId, const CString& strText, DWORD dwFormat, const RECT *pRect) { pDC->SetBkMode(TRANSPARENT); CRect rcCaptionMargins = GetThemeRect(iPartId, iStateId, TMT_CAPTIONMARGINS); rcCaptionMargins.top = rcCaptionMargins.bottom = 0; CRect rc(pRect); rc.DeflateRect(rcCaptionMargins); if (GetThemeEnumValue(iPartId, iStateId, TMT_CONTENTALIGNMENT) == CA_CENTER) { dwFormat |= DT_CENTER; } pDC->SetTextColor(GetThemeColor(iPartId, iStateId, TMT_TEXTCOLOR, pDC->GetTextColor())); if (GetThemeEnumValue(iPartId, iStateId, TMT_TEXTSHADOWTYPE) == TST_SINGLE) { CSize sz = GetThemeSize(iPartId, iStateId, TMT_TEXTSHADOWOFFSET); if (sz != CSize(0, 0)) { COLORREF clrShadow = GetThemeColor(iPartId, iStateId, TMT_TEXTSHADOWCOLOR); CRect rcShadow(rc); rcShadow.OffsetRect(sz); COLORREF clr = pDC->SetTextColor(clrShadow); pDC->DrawText(strText, rcShadow, dwFormat); pDC->SetTextColor(clr); } } pDC->DrawText(strText, rc, dwFormat); return TRUE; }
bool UGXPThemes::GetThemeRect(LPCWSTR theme, int iPartId, int iStateId, RECT *pRect) { bool success = false; if (useThemes) { HANDLE themeHandle = OpenThemeData(NULL, theme); if (themeHandle) { // v7.2 - update 01 - TD - VS 2008 defines this in vssym32.h (432) //#if _MSC_VER < 1500 //#if !defined(__VSSYM32_h__) #if !defined(TMT_DEFAULTPANESIZE) // correction - gastone const int TMT_DEFAULTPANESIZE = 5002; #endif HRESULT hr = GetThemeRect(themeHandle, iPartId, iStateId, TMT_DEFAULTPANESIZE, pRect); success = SUCCEEDED(hr); } } return success; }