Tested manually on XP, Win 7 and Win 10.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53049 Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com
-- v2: comctl32/toolbar: Don't use pattern brushes to draw checked background. comctl32/tests: Test that themed toolbar buttons don't use pattern brushes to draw checked background. comctl32/toolbar: Add support for TBCDRF_NOBACKGROUND.
From: Zhiyi Zhang zzhang@codeweavers.com
Tested manually on XP, Win 7 and Win 10.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53049 Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/comctl32/toolbar.c | 31 +++++++++++++++++-------------- include/commctrl.h | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 9b059996b65..bea294958c5 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -1062,20 +1062,23 @@ TOOLBAR_DrawButton (const TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HDC hdc,
if (theme) { - int partId = drawSepDropDownArrow ? TP_SPLITBUTTON : TP_BUTTON; - int stateId = TS_NORMAL; - - if (tbcd.nmcd.uItemState & CDIS_DISABLED) - stateId = TS_DISABLED; - else if (tbcd.nmcd.uItemState & CDIS_SELECTED) - stateId = TS_PRESSED; - else if (tbcd.nmcd.uItemState & CDIS_CHECKED) - stateId = (tbcd.nmcd.uItemState & CDIS_HOT) ? TS_HOTCHECKED : TS_CHECKED; - else if ((tbcd.nmcd.uItemState & CDIS_HOT) - || (drawSepDropDownArrow && btnPtr->bDropDownPressed)) - stateId = TS_HOT; - - DrawThemeBackground (theme, hdc, partId, stateId, &rc, NULL); + if (!(dwItemCDFlag & TBCDRF_NOBACKGROUND)) + { + int partId = drawSepDropDownArrow ? TP_SPLITBUTTON : TP_BUTTON; + int stateId = TS_NORMAL; + + if (tbcd.nmcd.uItemState & CDIS_DISABLED) + stateId = TS_DISABLED; + else if (tbcd.nmcd.uItemState & CDIS_SELECTED) + stateId = TS_PRESSED; + else if (tbcd.nmcd.uItemState & CDIS_CHECKED) + stateId = (tbcd.nmcd.uItemState & CDIS_HOT) ? TS_HOTCHECKED : TS_CHECKED; + else if ((tbcd.nmcd.uItemState & CDIS_HOT) + || (drawSepDropDownArrow && btnPtr->bDropDownPressed)) + stateId = TS_HOT; + + DrawThemeBackground(theme, hdc, partId, stateId, &rc, NULL); + } } else TOOLBAR_DrawFrame(infoPtr, &tbcd, &rc, dwItemCDFlag); diff --git a/include/commctrl.h b/include/commctrl.h index b829e4498ea..725ef64764f 100644 --- a/include/commctrl.h +++ b/include/commctrl.h @@ -1380,7 +1380,7 @@ typedef struct _NMTBCUSTOMDRAW #define TBCDRF_NOETCHEDEFFECT 0x00100000 /* No etched effect for */ /* disabled items */ #define TBCDRF_BLENDICON 0x00200000 /* ILD_BLEND50 on the icon image */ -#define TBCDRF_NOBACKGROUND 0x00400000 /* ILD_BLEND50 on the icon image */ +#define TBCDRF_NOBACKGROUND 0x00400000 /* Don't draw button background */ #define TBCDRF_USECDCOLORS 0x00800000
This merge request was approved by Alexandre Julliard.
From: Zhiyi Zhang zzhang@codeweavers.com
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org --- dlls/comctl32/tests/toolbar.c | 60 ++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 11 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 31c360304c6..897405098c2 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -62,6 +62,7 @@ static BOOL g_fExpectedHotItemOld; static BOOL g_fExpectedHotItemNew; static DWORD g_dwExpectedDispInfoMask; static BOOL g_ResetDispTextPtr; +static BOOL g_TestCheckedItemPrePaint;
static const struct message ttgetdispinfo_parent_seq[] = { { WM_NOTIFY, sent|id, 0, 0, TBN_GETINFOTIPA }, @@ -348,6 +349,28 @@ static LRESULT parent_wnd_notify(LPARAM lParam) } return 0; } + case NM_CUSTOMDRAW: + { + NMTBCUSTOMDRAW *cd = (NMTBCUSTOMDRAW *)lParam; + + switch (cd->nmcd.dwDrawStage) + { + case CDDS_PREPAINT: + return CDRF_NOTIFYITEMDRAW; + case CDDS_ITEMPREPAINT: + { + if (g_TestCheckedItemPrePaint) + { + cd->clrBtnHighlight = RGB(0xff, 0, 0); + cd->clrBtnFace = RGB(0xff, 0, 0); + return TBCDRF_NOBACKGROUND; + } + return CDRF_DODEFAULT; + } + } + + return 0; + } } return 0; } @@ -2617,34 +2640,49 @@ static void test_visual(void) HDC mem_dc1, mem_dc2, toolbar_dc; TBBUTTON tbbutton; int width, height; + COLORREF color; HTHEME theme; HWND toolbar; RECT rect; BOOL ret;
- if (!is_theme_active) - { - skip("Theming is not active, skipping visual tests.\n"); - return; - } - - /* Test that toolbar shouldn't use outside theme handles */ toolbar = CreateWindowA(TOOLBARCLASSNAMEA, "", WS_CHILD | WS_VISIBLE, 0, 0, 50, 50, hMainWnd, 0, 0, NULL); ok(!!toolbar, "Failed to create a toolbar window.\n");
- /* Toolbar needs data for it to show */ + /* Test that the comctl32 55AA pattern brush is not used to draw checked background when theming is on */ memset(&tbbutton, 0, sizeof(tbbutton)); - tbbutton.fsState = TBSTATE_ENABLED; - tbbutton.iString = (INT_PTR)"test"; + tbbutton.idCommand = 1000; + tbbutton.fsState = TBSTATE_ENABLED | TBSTATE_CHECKED; + tbbutton.iString = (INT_PTR)" "; SendMessageA(toolbar, TB_BUTTONSTRUCTSIZE, sizeof(tbbutton), 0); ret = SendMessageA(toolbar, TB_ADDBUTTONSA, 1, (LPARAM)&tbbutton); ok(ret, "TB_ADDBUTTONSA failed.\n"); flush_events(); + g_TestCheckedItemPrePaint = TRUE; + ret = RedrawWindow(toolbar, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW | RDW_UPDATENOW); + ok(ret, "RedrawWindow failed.\n"); + g_TestCheckedItemPrePaint = FALSE; + + toolbar_dc = GetDC(toolbar); + color = GetPixel(toolbar_dc, 5, 5); + if (is_theme_active) + todo_wine + ok(color != RGB(0xff, 0, 0), "Unexpected color %#lx.\n", color); + else + ok(color == RGB(0xff, 0, 0), "Unexpected color %#lx.\n", color);
+ if (!is_theme_active) + { + skip("Theming is not active, skipping the rest of visual tests.\n"); + ReleaseDC(toolbar, toolbar_dc); + DestroyWindow(toolbar); + return; + } + + /* Test that toolbar shouldn't use outside theme handles */ theme = pGetWindowTheme(toolbar); ok(!theme, "Expected theme not opened by window.\n");
- toolbar_dc = GetDC(toolbar); GetClientRect(toolbar, &rect); width = rect.right - rect.left; height = rect.bottom - rect.top;
From: Zhiyi Zhang zzhang@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53049 Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/comctl32/tests/toolbar.c | 1 - dlls/comctl32/toolbar.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 897405098c2..f66094a0b3a 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -2666,7 +2666,6 @@ static void test_visual(void) toolbar_dc = GetDC(toolbar); color = GetPixel(toolbar_dc, 5, 5); if (is_theme_active) - todo_wine ok(color != RGB(0xff, 0, 0), "Unexpected color %#lx.\n", color); else ok(color == RGB(0xff, 0, 0), "Unexpected color %#lx.\n", color); diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index bea294958c5..02538eeb649 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -1042,7 +1042,7 @@ TOOLBAR_DrawButton (const TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HDC hdc, (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))) OffsetRect(&rcText, 1, 1);
- if (!(tbcd.nmcd.uItemState & CDIS_HOT) && + if (!theme && !(tbcd.nmcd.uItemState & CDIS_HOT) && ((tbcd.nmcd.uItemState & CDIS_CHECKED) || (tbcd.nmcd.uItemState & CDIS_INDETERMINATE))) TOOLBAR_DrawPattern (&rc, &tbcd);