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 <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2022-02-09 16:45:13 +08:00 committed by Alexandre Julliard
parent 509d6a1d5f
commit c69d3bb781
2 changed files with 13 additions and 7 deletions

View File

@ -2796,6 +2796,7 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
UINT btn_type = get_button_type( dwStyle ); UINT btn_type = get_button_type( dwStyle );
int part = (btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX; int part = (btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX;
NMCUSTOMDRAW nmcd; NMCUSTOMDRAW nmcd;
HBRUSH brush;
LRESULT cdrf; LRESULT cdrf;
LOGFONTW lf; LOGFONTW lf;
HWND parent; 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; if (cdrf & CDRF_SKIPDEFAULT) goto cleanup;
DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL); 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) if (cdrf & CDRF_NOTIFYPOSTERASE)
{ {

View File

@ -843,14 +843,14 @@ static void test_themed_background(void)
{ANIMATE_CLASSA, 0, empty_seq, TRUE}, {ANIMATE_CLASSA, 0, empty_seq, TRUE},
{WC_BUTTONA, BS_PUSHBUTTON, pushbutton_seq}, {WC_BUTTONA, BS_PUSHBUTTON, pushbutton_seq},
{WC_BUTTONA, BS_DEFPUSHBUTTON, defpushbutton_seq}, {WC_BUTTONA, BS_DEFPUSHBUTTON, defpushbutton_seq},
{WC_BUTTONA, BS_CHECKBOX, checkbox_seq, TRUE}, {WC_BUTTONA, BS_CHECKBOX, checkbox_seq},
{WC_BUTTONA, BS_AUTOCHECKBOX, checkbox_seq, TRUE}, {WC_BUTTONA, BS_AUTOCHECKBOX, checkbox_seq},
{WC_BUTTONA, BS_RADIOBUTTON, radiobutton_seq, TRUE}, {WC_BUTTONA, BS_RADIOBUTTON, radiobutton_seq},
{WC_BUTTONA, BS_3STATE, checkbox_seq, TRUE}, {WC_BUTTONA, BS_3STATE, checkbox_seq},
{WC_BUTTONA, BS_AUTO3STATE, checkbox_seq, TRUE}, {WC_BUTTONA, BS_AUTO3STATE, checkbox_seq},
{WC_BUTTONA, BS_GROUPBOX, groupbox_seq, TRUE}, {WC_BUTTONA, BS_GROUPBOX, groupbox_seq, TRUE},
{WC_BUTTONA, BS_USERBUTTON, pushbutton_seq}, {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_PUSHBOX, radiobutton_seq, TRUE},
{WC_BUTTONA, BS_OWNERDRAW, ownerdrawbutton_seq}, {WC_BUTTONA, BS_OWNERDRAW, ownerdrawbutton_seq},
{WC_BUTTONA, BS_SPLITBUTTON, splitbutton_seq}, {WC_BUTTONA, BS_SPLITBUTTON, splitbutton_seq},
@ -950,7 +950,8 @@ static void test_themed_background(void)
{ {
/* WM_CTLCOLORSTATIC is used to fill background */ /* WM_CTLCOLORSTATIC is used to fill background */
color = GetPixel(hdc, 40, 40); 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); ok(color == 0x808080, "Expected color %#x, got %#x.\n", 0x808080, color);
} }
else if (tests[i].seq == groupbox_seq) else if (tests[i].seq == groupbox_seq)