comctl32: treeview: Fixed bug

Chris Peterson Chrisp at ucla.edu
Fri Mar 16 16:27:04 CDT 2007


This is a fix for a defect that was discovered by my getter and setter 
tests. It simply allows the control to correctly report that it is using 
the system's window color, and actually use it at the same time. This 
patch only fixes a single todo_wine. As always, any comments/suggestions 
are welcome.
Thanks!
-Chris
-------------- next part --------------
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 3c7e9f5..f26b41d 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -326,11 +326,9 @@ static void TestGetSetBkColor(void)
 {
     COLORREF crColor = RGB(0,0,0);
 
-    todo_wine{
-        /* If the value is -1, the control is using the system color for the background color. */
-        crColor = (COLORREF)SendMessage( hTree, TVM_GETBKCOLOR, 0, 0 );
-        ok(crColor == -1, "Default background color reported as 0x%.8x\n", crColor);
-    }
+    /* If the value is -1, the control is using the system color for the background color. */
+    crColor = (COLORREF)SendMessage( hTree, TVM_GETBKCOLOR, 0, 0 );
+    ok(crColor == -1, "Default background color reported as 0x%.8x\n", crColor);
 
     /* Test for black background */
     SendMessage( hTree, TVM_SETBKCOLOR, 0, (LPARAM)RGB(0,0,0) );
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 8ababc9..d907b35 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -197,6 +197,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(treeview);
 #define OVERLAYIMAGEINDEX(x) (((x) >> 8) & 0x0f)
 #define ISVISIBLE(x)         ((x)->visibleOrder >= 0)
 
+#define DECODECOLOR(x,y)     (((x) == -1) ? GetSysColor(y) : (x))
+
 
 static const WCHAR themeClass[] = { 'T','r','e','e','v','i','e','w',0 };
 
@@ -640,7 +642,7 @@ TREEVIEW_SendCustomDrawNotify(TREEVIEW_INFO *infoPtr, DWORD dwDrawStage,
     nmcd->uItemState = 0;
     nmcd->lItemlParam = 0;
     nmcdhdr.clrText = infoPtr->clrText;
-    nmcdhdr.clrTextBk = infoPtr->clrBk;
+    nmcdhdr.clrTextBk = DECODECOLOR(infoPtr->clrBk, COLOR_WINDOW);
     nmcdhdr.iLevel = 0;
 
     return (BOOL)TREEVIEW_SendRealNotify(infoPtr,
@@ -2318,7 +2320,7 @@ TREEVIEW_DrawItemLines(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
     if (!lar && item->iLevel == 0)
 	return;
 
-    hbr    = CreateSolidBrush(infoPtr->clrBk);
+    hbr    = CreateSolidBrush( DECODECOLOR(infoPtr->clrBk,COLOR_WINDOW) );
     hbrOld = SelectObject(hdc, hbr);
     
     centerx = (item->linesOffset + item->stateOffset) / 2;
@@ -2429,10 +2431,12 @@ TREEVIEW_DrawItemLines(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
     
                     if (!(item->state & TVIS_EXPANDED))
                     {
+                        COLORREF crBkColor;
                         Rectangle(hdc, centerx - 1, centery - plussize + 1,
                         centerx + 2, centery + plussize);
-                        SetPixel(hdc, centerx - 1, centery, infoPtr->clrBk);
-                        SetPixel(hdc, centerx + 1, centery, infoPtr->clrBk);
+                        crBkColor = DECODECOLOR(infoPtr->clrBk, COLOR_WINDOW);
+                        SetPixel(hdc, centerx - 1, centery, crBkColor);
+                        SetPixel(hdc, centerx + 1, centery, crBkColor);
                     }
                 }
             }
@@ -2480,7 +2484,7 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem)
     }
     else
     {
-	nmcdhdr.clrTextBk = infoPtr->clrBk;
+        nmcdhdr.clrTextBk = DECODECOLOR(infoPtr->clrBk, COLOR_WINDOW);
 	if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem))
 	    nmcdhdr.clrText = comctl32_color.clrHighlight;
 	else if (infoPtr->clrText == -1)
@@ -2791,7 +2795,7 @@ TREEVIEW_UpdateScrollBars(TREEVIEW_INFO *infoPtr)
 static LRESULT
 TREEVIEW_EraseBackground(TREEVIEW_INFO *infoPtr, HDC hDC)
 {
-    HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk);
+    HBRUSH hBrush = CreateSolidBrush( DECODECOLOR(infoPtr->clrBk, COLOR_WINDOW) );
     RECT rect;
 
     GetClientRect(infoPtr->hwnd, &rect);
@@ -4875,7 +4879,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
 
     infoPtr->scrollX = 0;
 
-    infoPtr->clrBk = GetSysColor(COLOR_WINDOW);
+    infoPtr->clrBk = -1;    /* use system color */
     infoPtr->clrText = -1;	/* use system color */
     infoPtr->clrLine = RGB(128, 128, 128);
     infoPtr->clrInsertMark = GetSysColor(COLOR_BTNTEXT);


More information about the wine-patches mailing list