[PATCH 5/7] comctl32/button: Use the brush from WM_CTLCOLORBTN to fill background for push buttons.

Zhiyi Zhang zzhang at codeweavers.com
Wed Feb 9 02:45:01 CST 2022


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 at codeweavers.com>
---
 dlls/comctl32/button.c     | 7 +++++++
 dlls/comctl32/tests/misc.c | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index 88b48a4a5c0..14b2200afed 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -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)
diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c
index 72674ea5942..09c5b3d6c40 100644
--- a/dlls/comctl32/tests/misc.c
+++ b/dlls/comctl32/tests/misc.c
@@ -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},
-- 
2.32.0




More information about the wine-devel mailing list