comctl32/button: Use the brush from WM_CTLCOLORBTN to fill background for push buttons.

The brush from WM_CTLCOLORBTN is used for filling background for push buttons after a DrawThemeParentBackground() call
according to tests.

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:01 +08:00 committed by Alexandre Julliard
parent 179117a689
commit 509d6a1d5f
2 changed files with 10 additions and 3 deletions

View File

@ -2729,6 +2729,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
{
RECT bgRect, labelRect, imageRect, textRect, focusRect;
NMCUSTOMDRAW nmcd;
HBRUSH brush;
LRESULT cdrf;
HWND parent;
@ -2748,7 +2749,13 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
if (cdrf & CDRF_SKIPDEFAULT) return;
if (IsThemeBackgroundPartiallyTransparent(theme, BP_PUSHBUTTON, state))
{
DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL);
/* Tests show that the brush from WM_CTLCOLORBTN is used for filling background after a
* DrawThemeParentBackground() call */
brush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
FillRect(hDC, &bgRect, brush ? brush : GetSysColorBrush(COLOR_BTNFACE));
}
DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL);
if (cdrf & CDRF_NOTIFYPOSTERASE)

View File

@ -841,15 +841,15 @@ static void test_themed_background(void)
tests[] =
{
{ANIMATE_CLASSA, 0, empty_seq, TRUE},
{WC_BUTTONA, BS_PUSHBUTTON, pushbutton_seq, TRUE},
{WC_BUTTONA, BS_DEFPUSHBUTTON, defpushbutton_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_GROUPBOX, groupbox_seq, TRUE},
{WC_BUTTONA, BS_USERBUTTON, pushbutton_seq, TRUE},
{WC_BUTTONA, BS_USERBUTTON, pushbutton_seq},
{WC_BUTTONA, BS_AUTORADIOBUTTON, radiobutton_seq, TRUE},
{WC_BUTTONA, BS_PUSHBOX, radiobutton_seq, TRUE},
{WC_BUTTONA, BS_OWNERDRAW, ownerdrawbutton_seq},