comctl32: Correctly report systemcolor use for Treeview background
Nikolay Sivov
bunglehead at gmail.com
Sat Feb 28 14:47:49 CST 2009
Changelog:
- store background color internally as -1 for syscolor for transparent
TVM_[G,S]ETBKCOLOR handling
- TVM_SETCOLOR works correctly now with lParam = -1 (revert to syscolor)
>From 6128c1b52f161a77d66e75853744029c434c3f57 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sat, 28 Feb 2009 15:32:02 -0500
Subject: Correctly report systemcolor use for Treeview background
---
dlls/comctl32/tests/treeview.c | 8 +++-----
dlls/comctl32/treeview.c | 18 ++++++++++++------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index f93b485..9ef6a99 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -427,11 +427,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 abc6fc7..43ae7b6 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -2306,11 +2306,13 @@ TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITE
& (TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS))
> TVS_LINESATROOT);
HBRUSH hbr, hbrOld;
+ COLORREF clrBk = infoPtr->clrBk == -1 ? GetSysColor(COLOR_WINDOW):
+ infoPtr->clrBk;
if (!lar && item->iLevel == 0)
return;
- hbr = CreateSolidBrush(infoPtr->clrBk);
+ hbr = CreateSolidBrush(clrBk);
hbrOld = SelectObject(hdc, hbr);
centerx = (item->linesOffset + item->stateOffset) / 2;
@@ -2423,8 +2425,8 @@ TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITE
{
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);
+ SetPixel(hdc, centerx - 1, centery, clrBk);
+ SetPixel(hdc, centerx + 1, centery, clrBk);
}
}
}
@@ -2472,7 +2474,8 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem
}
else
{
- nmcdhdr.clrTextBk = infoPtr->clrBk;
+ nmcdhdr.clrTextBk = infoPtr->clrBk == -1 ? GetSysColor(COLOR_WINDOW):
+ infoPtr->clrBk;
if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem))
nmcdhdr.clrText = comctl32_color.clrHighlight;
else if (infoPtr->clrText == -1)
@@ -2782,9 +2785,12 @@ TREEVIEW_UpdateScrollBars(TREEVIEW_INFO *infoPtr)
static LRESULT
TREEVIEW_EraseBackground(const TREEVIEW_INFO *infoPtr, HDC hDC)
{
- HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk);
+ HBRUSH hBrush;
+ COLORREF clrBk = infoPtr->clrBk == -1 ? GetSysColor(COLOR_WINDOW):
+ infoPtr->clrBk;
RECT rect;
+ hBrush = CreateSolidBrush(clrBk);
GetClientRect(infoPtr->hwnd, &rect);
FillRect(hDC, &rect, hBrush);
DeleteObject(hBrush);
@@ -4937,7 +4943,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);
--
1.5.6.5
More information about the wine-patches
mailing list