From c69d3bb78115b6037edec8b396374a30b2ce6e27 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Wed, 9 Feb 2022 16:45:13 +0800 Subject: [PATCH] comctl32/button: Use the brush from WM_CTLCOLORSTATIC to fill background for checkboxes and radio buttons. Fix radio buttons of Mupen64-RR-Lua input window having stale background. Mupen64-RR-Lua doesn't actually handle WM_ERASEBKGND even though it returns nonzero. And tests show that a WM_CTLCOLORSTATIC is sent and the returned brush is used for filling background, even painting over the content from DrawThemeParentBackground(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52433 Signed-off-by: Zhiyi Zhang Signed-off-by: Alexandre Julliard --- dlls/comctl32/button.c | 5 +++++ dlls/comctl32/tests/misc.c | 15 ++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index 14b2200afed..1349e10c4c0 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -2796,6 +2796,7 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in UINT btn_type = get_button_type( dwStyle ); int part = (btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX; NMCUSTOMDRAW nmcd; + HBRUSH brush; LRESULT cdrf; LOGFONTW lf; HWND parent; @@ -2859,6 +2860,10 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in if (cdrf & CDRF_SKIPDEFAULT) goto cleanup; DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL); + /* Tests show that the brush from WM_CTLCOLORSTATIC is used for filling background after a + * DrawThemeParentBackground() call */ + brush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd); + FillRect(hDC, &client_rect, brush ? brush : GetSysColorBrush(COLOR_BTNFACE)); if (cdrf & CDRF_NOTIFYPOSTERASE) { diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c index 09c5b3d6c40..c3de9e68c5a 100644 --- a/dlls/comctl32/tests/misc.c +++ b/dlls/comctl32/tests/misc.c @@ -843,14 +843,14 @@ static void test_themed_background(void) {ANIMATE_CLASSA, 0, empty_seq, TRUE}, {WC_BUTTONA, BS_PUSHBUTTON, pushbutton_seq}, {WC_BUTTONA, BS_DEFPUSHBUTTON, defpushbutton_seq}, - {WC_BUTTONA, BS_CHECKBOX, checkbox_seq, TRUE}, - {WC_BUTTONA, BS_AUTOCHECKBOX, checkbox_seq, TRUE}, - {WC_BUTTONA, BS_RADIOBUTTON, radiobutton_seq, TRUE}, - {WC_BUTTONA, BS_3STATE, checkbox_seq, TRUE}, - {WC_BUTTONA, BS_AUTO3STATE, checkbox_seq, TRUE}, + {WC_BUTTONA, BS_CHECKBOX, checkbox_seq}, + {WC_BUTTONA, BS_AUTOCHECKBOX, checkbox_seq}, + {WC_BUTTONA, BS_RADIOBUTTON, radiobutton_seq}, + {WC_BUTTONA, BS_3STATE, checkbox_seq}, + {WC_BUTTONA, BS_AUTO3STATE, checkbox_seq}, {WC_BUTTONA, BS_GROUPBOX, groupbox_seq, TRUE}, {WC_BUTTONA, BS_USERBUTTON, pushbutton_seq}, - {WC_BUTTONA, BS_AUTORADIOBUTTON, radiobutton_seq, TRUE}, + {WC_BUTTONA, BS_AUTORADIOBUTTON, radiobutton_seq}, {WC_BUTTONA, BS_PUSHBOX, radiobutton_seq, TRUE}, {WC_BUTTONA, BS_OWNERDRAW, ownerdrawbutton_seq}, {WC_BUTTONA, BS_SPLITBUTTON, splitbutton_seq}, @@ -950,7 +950,8 @@ static void test_themed_background(void) { /* WM_CTLCOLORSTATIC is used to fill background */ color = GetPixel(hdc, 40, 40); - todo_wine + /* BS_PUSHBOX is unimplemented on Wine */ + todo_wine_if(i == 11) ok(color == 0x808080, "Expected color %#x, got %#x.\n", 0x808080, color); } else if (tests[i].seq == groupbox_seq)