[PATCH 4/4] comctl32/button: Do not set BS_PUSHBUTTON and BS_DEFPUSHBUTTON style directly to Split Buttons and Command Links.

Zhiyi Zhang zzhang at codeweavers.com
Wed May 6 03:47:58 CDT 2020


For Split Buttons and Command Links of common control version 6, setting
BS_PUSHBUTTON and BS_DEFPUSHBUTTON style toggles their default bit.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47621
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/comctl32/button.c       | 12 +++++++++---
 dlls/comctl32/tests/button.c |  1 -
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index b615df4a165..4f7a3052b10 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -847,8 +847,14 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
         break;
 
     case BM_SETSTYLE:
-        btn_type = wParam & BS_TYPEMASK;
-        style = (style & ~BS_TYPEMASK) | btn_type;
+    {
+        DWORD new_btn_type;
+
+        new_btn_type= wParam & BS_TYPEMASK;
+        if (btn_type >= BS_SPLITBUTTON && new_btn_type <= BS_DEFPUSHBUTTON)
+            new_btn_type = (btn_type & ~BS_DEFPUSHBUTTON) | new_btn_type;
+
+        style = (style & ~BS_TYPEMASK) | new_btn_type;
         SetWindowLongW( hWnd, GWL_STYLE, style );
 
         /* Only redraw if lParam flag is set.*/
@@ -856,7 +862,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
             InvalidateRect( hWnd, NULL, TRUE );
 
         break;
-
+    }
     case BM_CLICK:
 	SendMessageW( hWnd, WM_LBUTTONDOWN, 0, 0 );
 	SendMessageW( hWnd, WM_LBUTTONUP, 0, 0 );
diff --git a/dlls/comctl32/tests/button.c b/dlls/comctl32/tests/button.c
index 933db6e9825..716850073ff 100644
--- a/dlls/comctl32/tests/button.c
+++ b/dlls/comctl32/tests/button.c
@@ -2303,7 +2303,6 @@ static void test_style(void)
             else
                 expected_type = j;
 
-            todo_wine_if(i >= BS_SPLITBUTTON && j <= BS_DEFPUSHBUTTON)
             ok(type == expected_type || broken(type == j), /* XP */
                     "Original type %#x, expected new type %#x, got %#x.\n", i, expected_type, type);
         }
-- 
2.25.1



More information about the wine-devel mailing list