comctl32: Set the text and bkgnd colours to the default before the item pre-paint notification.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2016-12-06 10:25:26 +00:00 committed by Alexandre Julliard
parent 3f0002020a
commit 3ed6ba579e
2 changed files with 19 additions and 6 deletions

View File

@ -42,6 +42,7 @@ static BOOL g_disp_A_to_W;
static BOOL g_disp_set_stateimage;
static BOOL g_beginedit_alter_text;
static HFONT g_customdraw_font;
static BOOL g_v6;
#define NUM_MSG_SEQUENCES 3
#define TREEVIEW_SEQ_INDEX 0
@ -1261,6 +1262,7 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
{
NMTVCUSTOMDRAW *nmcd = (NMTVCUSTOMDRAW*)lParam;
COLORREF c0ffee = RGB(0xc0,0xff,0xee), cafe = RGB(0xca,0xfe,0x00);
COLORREF text = GetTextColor(nmcd->nmcd.hdc), bkgnd = GetBkColor(nmcd->nmcd.hdc);
msg.flags |= custdraw;
msg.stage = nmcd->nmcd.dwDrawStage;
@ -1271,15 +1273,23 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW|CDRF_NOTIFYITEMERASE|CDRF_NOTIFYPOSTPAINT;
case CDDS_ITEMPREPAINT:
nmcd->clrTextBk = c0ffee;
ok(text == nmcd->clrText || (g_v6 && nmcd->clrText == 0xffffffff),
"got %08x vs %08x\n", text, nmcd->clrText);
ok(bkgnd == nmcd->clrTextBk || (g_v6 && nmcd->clrTextBk == 0xffffffff),
"got %08x vs %08x\n", bkgnd, nmcd->clrTextBk);
nmcd->clrText = cafe;
nmcd->clrTextBk = c0ffee;
SetTextColor(nmcd->nmcd.hdc, c0ffee);
SetBkColor(nmcd->nmcd.hdc, cafe);
if (g_customdraw_font)
SelectObject(nmcd->nmcd.hdc, g_customdraw_font);
return CDRF_NOTIFYPOSTPAINT|CDRF_NEWFONT;
case CDDS_ITEMPOSTPAINT:
/* at the point of post paint notification colors are already restored */
ok(GetTextColor(nmcd->nmcd.hdc) != cafe, "got 0%x\n", GetTextColor(nmcd->nmcd.hdc));
ok(GetBkColor(nmcd->nmcd.hdc) != c0ffee, "got 0%x\n", GetBkColor(nmcd->nmcd.hdc));
ok(nmcd->clrText == cafe, "got 0%x\n", nmcd->clrText);
ok(nmcd->clrTextBk == c0ffee, "got 0%x\n", nmcd->clrTextBk);
ok(text != cafe, "got 0%x\n", text);
ok(bkgnd != c0ffee, "got 0%x\n", bkgnd);
if (g_customdraw_font)
ok(GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT) != g_customdraw_font, "got %p\n",
GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT));
@ -2471,6 +2481,7 @@ START_TEST(treeview)
}
/* comctl32 version 6 tests start here */
g_v6 = TRUE;
test_expandedimage();
test_htreeitem_layout();
test_WM_GETDLGCODE();

View File

@ -2552,6 +2552,8 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
}
hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, item));
oldTextColor = SetTextColor(hdc, nmcdhdr.clrText);
oldTextBkColor = SetBkColor(hdc, nmcdhdr.clrTextBk);
/* The custom draw handler can query the text rectangle,
* so get ready. */
@ -2586,9 +2588,9 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
TREEVIEW_DrawItemLines(infoPtr, hdc, item);
/* Set colors. Custom draw handler can change these so we do this after it. */
oldTextColor = SetTextColor(hdc, nmcdhdr.clrText);
oldTextBkColor = SetBkColor(hdc, nmcdhdr.clrTextBk);
/* reset colors. Custom draw handler can change them */
SetTextColor(hdc, nmcdhdr.clrText);
SetBkColor(hdc, nmcdhdr.clrTextBk);
centery = (item->rect.top + item->rect.bottom) / 2;