Phil Krylov : comctl32: Fix emitting of NM_CUSTOMDRAW header notifications.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jan 10 14:14:02 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 1b9fc2a170b17888e71fa229657d02240f37ffb5
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=1b9fc2a170b17888e71fa229657d02240f37ffb5

Author: Phil Krylov <phil at newstar.rinet.ru>
Date:   Tue Jan 10 19:58:24 2006 +0100

comctl32: Fix emitting of NM_CUSTOMDRAW header notifications.
Emit NM_CUSTOMDRAW header notifications for all headers, not only
ownerdrawn. Allow to change item text and background colors in an
application's NM_CUSTOMDRAW handler.

---

 dlls/comctl32/header.c |   40 +++++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c
index 4b533fc..5e1c4c8 100644
--- a/dlls/comctl32/header.c
+++ b/dlls/comctl32/header.c
@@ -166,6 +166,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT
     RECT r;
     INT  oldBkMode, cxEdge = GetSystemMetrics(SM_CXEDGE);
     HTHEME theme = GetWindowTheme (hwnd);
+    NMCUSTOMDRAW nmcd;
 
     TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, infoPtr->bUnicode);
 
@@ -205,22 +206,24 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT
     r.left  -= cxEdge;
     r.right += cxEdge;
 
+    /* Set the colors before sending NM_CUSTOMDRAW so that it can change them */
+    SetTextColor (hdc, (bHotTrack && !theme) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
+    SetBkColor(hdc, GetSysColor(COLOR_3DFACE));
+
+    nmcd.hdr.hwndFrom = hwnd;
+    nmcd.hdr.idFrom   = GetWindowLongPtrW (hwnd, GWLP_ID);
+    nmcd.hdr.code     = NM_CUSTOMDRAW;
+    nmcd.dwDrawStage  = CDDS_PREPAINT | CDDS_ITEM | CDDS_ITEMPOSTERASE;
+    nmcd.hdc          = hdc;
+    nmcd.dwItemSpec   = iItem;
+    nmcd.rc           = r;
+    nmcd.uItemState   = phdi->bDown ? CDIS_SELECTED : 0;
+    nmcd.lItemlParam  = phdi->lParam;
+
+    SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+
     if (phdi->fmt & HDF_OWNERDRAW) {
 	DRAWITEMSTRUCT dis;
-	NMCUSTOMDRAW nmcd;
-	
-	nmcd.hdr.hwndFrom = hwnd;
-	nmcd.hdr.idFrom   = GetWindowLongPtrW (hwnd, GWLP_ID);
-	nmcd.hdr.code     = NM_CUSTOMDRAW;
-	nmcd.dwDrawStage  = CDDS_PREPAINT | CDDS_ITEM | CDDS_ITEMPOSTERASE;
-	nmcd.hdc          = hdc;
-	nmcd.dwItemSpec   = iItem;
-	nmcd.rc           = r;
-	nmcd.uItemState   = phdi->bDown ? CDIS_SELECTED : 0;
-	nmcd.lItemlParam  = phdi->lParam;
-
-	SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
-			(WPARAM)nmcd.hdr.idFrom, (LPARAM)&nmcd);
 
 	dis.CtlType    = ODT_HEADER;
 	dis.CtlID      = GetWindowLongPtrW (hwnd, GWLP_ID);
@@ -249,6 +252,14 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT
 	rw = r.right - r.left;
 	rh = r.bottom - r.top;
 
+        if (theme == NULL) {
+            HBRUSH hbr = CreateSolidBrush(GetBkColor(hdc));
+            RECT rcBackground = r;
+
+            rcBackground.right -= cxEdge;
+            FillRect(hdc, &rcBackground, hbr);
+            DeleteObject(hbr);
+        }
 	if (phdi->fmt & HDF_STRING) {
 	    RECT textRect;
 
@@ -344,7 +355,6 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT
 				   HDF_BITMAP_ON_RIGHT|HDF_IMAGE)))) /* no explicit format specified? */
 	    && (phdi->pszText)) {
 	    oldBkMode = SetBkMode(hdc, TRANSPARENT);
-	    SetTextColor (hdc, (bHotTrack && !theme) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
 	    r.left  = tx;
 	    r.right = tx + tw;
 	    DrawTextW (hdc, phdi->pszText, -1,




More information about the wine-cvs mailing list