From e7116725ff6bd082ffd97ad0b3813ab2104ea618 Mon Sep 17 00:00:00 2001 From: Mark Harmstone Date: Tue, 24 Mar 2015 07:40:59 +0000 Subject: [PATCH] comctl32: Use correct font for themed headers. --- dlls/comctl32/header.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index 59f2c1249b2..7c632f3cc59 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -333,6 +333,7 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU INT oldBkMode; HTHEME theme = GetWindowTheme (infoPtr->hwndSelf); NMCUSTOMDRAW nmcd; + int state = 0; TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, (infoPtr->nNotifyFormat == NFR_UNICODE)); @@ -340,6 +341,9 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU if (r.right - r.left == 0) return phdi->rect.right; + if (theme) + state = (phdi->bDown) ? HIS_PRESSED : (bHotTrack ? HIS_HOT : HIS_NORMAL); + /* Set the colors before sending NM_CUSTOMDRAW so that it can change them */ SetTextColor(hdc, (bHotTrack && !theme) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT); SetBkColor(hdc, comctl32_color.clr3dFace); @@ -418,8 +422,14 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU RECT textRect; SetRectEmpty(&textRect); - DrawTextW (hdc, phdi->pszText, -1, - &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT); + + if (theme) { + GetThemeTextExtent(theme, hdc, HP_HEADERITEM, state, phdi->pszText, -1, + DT_LEFT|DT_VCENTER|DT_SINGLELINE, NULL, &textRect); + } else { + DrawTextW (hdc, phdi->pszText, -1, + &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT); + } cw = textRect.right - textRect.left + 2 * infoPtr->iMargin; } @@ -512,8 +522,14 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU oldBkMode = SetBkMode(hdc, TRANSPARENT); r.left = tx; r.right = tx + tw; - DrawTextW (hdc, phdi->pszText, -1, - &r, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE); + if (theme) { + DrawThemeText(theme, hdc, HP_HEADERITEM, state, phdi->pszText, + -1, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE, + 0, &r); + } else { + DrawTextW (hdc, phdi->pszText, -1, + &r, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE); + } if (oldBkMode != TRANSPARENT) SetBkMode(hdc, oldBkMode); }