[UXTHEME] -Simplify ThemeDrawCaptionText.

svn path=/trunk/; revision=74551
This commit is contained in:
Giannis Adamopoulos 2017-05-15 15:34:43 +00:00
parent ba88179c67
commit 98917d7d98

View file

@ -109,9 +109,7 @@ WCHAR *UserGetWindowCaption(HWND hwnd)
return text; return text;
} }
HRESULT WINAPI ThemeDrawCaptionText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, HRESULT WINAPI ThemeDrawCaptionText(PDRAW_CONTEXT pcontext, RECT* pRect, int iPartId, int iStateId, LPCWSTR pszText)
LPCWSTR pszText, int iCharCount, DWORD dwTextFlags,
DWORD dwTextFlags2, const RECT *pRect, BOOL Active)
{ {
HRESULT hr; HRESULT hr;
HFONT hFont = NULL; HFONT hFont = NULL;
@ -119,33 +117,34 @@ HRESULT WINAPI ThemeDrawCaptionText(HTHEME hTheme, HDC hdc, int iPartId, int iSt
LOGFONTW logfont; LOGFONTW logfont;
COLORREF textColor; COLORREF textColor;
COLORREF oldTextColor; COLORREF oldTextColor;
int oldBkMode;
RECT rt;
hr = GetThemeSysFont(0,TMT_CAPTIONFONT,&logfont); hr = GetThemeSysFont(0,TMT_CAPTIONFONT,&logfont);
if(SUCCEEDED(hr))
if(SUCCEEDED(hr)) {
hFont = CreateFontIndirectW(&logfont); hFont = CreateFontIndirectW(&logfont);
}
CopyRect(&rt, pRect);
if(hFont)
oldFont = SelectObject(hdc, hFont);
if(dwTextFlags2 & DTT_GRAYED) if(hFont)
textColor = GetSysColor(COLOR_GRAYTEXT); oldFont = SelectObject(pcontext->hDC, hFont);
else if (!Active)
if (!pcontext->Active)
textColor = GetSysColor(COLOR_INACTIVECAPTIONTEXT); textColor = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
else else
textColor = GetSysColor(COLOR_CAPTIONTEXT); textColor = GetSysColor(COLOR_CAPTIONTEXT);
oldTextColor = SetTextColor(hdc, textColor); oldTextColor = SetTextColor(pcontext->hDC, textColor);
oldBkMode = SetBkMode(hdc, TRANSPARENT); DrawThemeText(pcontext->theme,
DrawThemeText(hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, dwTextFlags, pRect); pcontext->hDC,
SetBkMode(hdc, oldBkMode); iPartId,
SetTextColor(hdc, oldTextColor); iStateId,
pszText,
lstrlenW(pszText),
DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS,
0,
pRect);
SetTextColor(pcontext->hDC, oldTextColor);
if(hFont) { if(hFont)
SelectObject(hdc, oldFont); {
SelectObject(pcontext->hDC, oldFont);
DeleteObject(hFont); DeleteObject(hFont);
} }
return S_OK; return S_OK;
@ -381,17 +380,7 @@ ThemeDrawCaption(PDRAW_CONTEXT pcontext, RECT* prcCurrent)
/* Draw the caption */ /* Draw the caption */
if (CaptionText) if (CaptionText)
{ {
/* FIXME: Use DrawThemeTextEx */ ThemeDrawCaptionText(pcontext, &rcPart, iPart, iState, CaptionText);
ThemeDrawCaptionText(pcontext->theme,
pcontext->hDC,
iPart,
iState,
CaptionText,
lstrlenW(CaptionText),
DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS,
0,
&rcPart,
pcontext->Active);
HeapFree(GetProcessHeap(), 0, CaptionText); HeapFree(GetProcessHeap(), 0, CaptionText);
} }
} }