Commit 3ed6ba57 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

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

parent 3f000202
...@@ -42,6 +42,7 @@ static BOOL g_disp_A_to_W; ...@@ -42,6 +42,7 @@ static BOOL g_disp_A_to_W;
static BOOL g_disp_set_stateimage; static BOOL g_disp_set_stateimage;
static BOOL g_beginedit_alter_text; static BOOL g_beginedit_alter_text;
static HFONT g_customdraw_font; static HFONT g_customdraw_font;
static BOOL g_v6;
#define NUM_MSG_SEQUENCES 3 #define NUM_MSG_SEQUENCES 3
#define TREEVIEW_SEQ_INDEX 0 #define TREEVIEW_SEQ_INDEX 0
...@@ -1261,6 +1262,7 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, ...@@ -1261,6 +1262,7 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
{ {
NMTVCUSTOMDRAW *nmcd = (NMTVCUSTOMDRAW*)lParam; NMTVCUSTOMDRAW *nmcd = (NMTVCUSTOMDRAW*)lParam;
COLORREF c0ffee = RGB(0xc0,0xff,0xee), cafe = RGB(0xca,0xfe,0x00); 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.flags |= custdraw;
msg.stage = nmcd->nmcd.dwDrawStage; msg.stage = nmcd->nmcd.dwDrawStage;
...@@ -1271,15 +1273,23 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, ...@@ -1271,15 +1273,23 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
case CDDS_PREPAINT: case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW|CDRF_NOTIFYITEMERASE|CDRF_NOTIFYPOSTPAINT; return CDRF_NOTIFYITEMDRAW|CDRF_NOTIFYITEMERASE|CDRF_NOTIFYPOSTPAINT;
case CDDS_ITEMPREPAINT: 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->clrText = cafe;
nmcd->clrTextBk = c0ffee;
SetTextColor(nmcd->nmcd.hdc, c0ffee);
SetBkColor(nmcd->nmcd.hdc, cafe);
if (g_customdraw_font) if (g_customdraw_font)
SelectObject(nmcd->nmcd.hdc, g_customdraw_font); SelectObject(nmcd->nmcd.hdc, g_customdraw_font);
return CDRF_NOTIFYPOSTPAINT|CDRF_NEWFONT; return CDRF_NOTIFYPOSTPAINT|CDRF_NEWFONT;
case CDDS_ITEMPOSTPAINT: case CDDS_ITEMPOSTPAINT:
/* at the point of post paint notification colors are already restored */ /* 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(nmcd->clrText == cafe, "got 0%x\n", nmcd->clrText);
ok(GetBkColor(nmcd->nmcd.hdc) != c0ffee, "got 0%x\n", GetBkColor(nmcd->nmcd.hdc)); 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) if (g_customdraw_font)
ok(GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT) != g_customdraw_font, "got %p\n", ok(GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT) != g_customdraw_font, "got %p\n",
GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT)); GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT));
...@@ -2471,6 +2481,7 @@ START_TEST(treeview) ...@@ -2471,6 +2481,7 @@ START_TEST(treeview)
} }
/* comctl32 version 6 tests start here */ /* comctl32 version 6 tests start here */
g_v6 = TRUE;
test_expandedimage(); test_expandedimage();
test_htreeitem_layout(); test_htreeitem_layout();
test_WM_GETDLGCODE(); test_WM_GETDLGCODE();
......
...@@ -2552,6 +2552,8 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item) ...@@ -2552,6 +2552,8 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
} }
hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, 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, /* The custom draw handler can query the text rectangle,
* so get ready. */ * so get ready. */
...@@ -2586,9 +2588,9 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item) ...@@ -2586,9 +2588,9 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
TREEVIEW_DrawItemLines(infoPtr, hdc, item); TREEVIEW_DrawItemLines(infoPtr, hdc, item);
/* Set colors. Custom draw handler can change these so we do this after it. */ /* reset colors. Custom draw handler can change them */
oldTextColor = SetTextColor(hdc, nmcdhdr.clrText); SetTextColor(hdc, nmcdhdr.clrText);
oldTextBkColor = SetBkColor(hdc, nmcdhdr.clrTextBk); SetBkColor(hdc, nmcdhdr.clrTextBk);
centery = (item->rect.top + item->rect.bottom) / 2; centery = (item->rect.top + item->rect.bottom) / 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment