Mark Harmstone : comctl32: Use correct font for themed headers.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 24 10:00:44 CDT 2015


Module: wine
Branch: master
Commit: e7116725ff6bd082ffd97ad0b3813ab2104ea618
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e7116725ff6bd082ffd97ad0b3813ab2104ea618

Author: Mark Harmstone <hellas at burntcomma.com>
Date:   Tue Mar 24 07:40:59 2015 +0000

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 59f2c12..7c632f3 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);
         }




More information about the wine-cvs mailing list