https://git.reactos.org/?p=reactos.git;a=commitdiff;h=780f2ba2159575f4f0edf1a97475a5edaa2f7a6b

commit 780f2ba2159575f4f0edf1a97475a5edaa2f7a6b
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Sun Mar 24 17:01:07 2019 +0100
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sun Mar 24 17:23:24 2019 +0100

    [USER32][COMCTL32] Move the auto radio button group logic from BM_SETCHECK 
to WM_LBUTTONUP handler.
    CORE-8526
    
    Import Wine commit:
    
https://source.winehq.org/git/wine.git/commit/96d0af52eb0d14084397647b974c5efebb59d0f0
    
    "user32: Move the auto radio button group logic from BM_SETCHECK to 
WM_LBUTTONUP handler.
    This patch also changes the logic to get the control style with 
WM_GETDLGCODE
    instead of GetWindowLong to make the message test pass.
    "
    by Dmitry Timoshkov.
    See bug report https://bugs.winehq.org/show_bug.cgi?id=42010
    
    - (ReactOS-only) Fix also the corresponding logic in COMCTL32.
---
 dll/win32/comctl32/button.c           | 15 +++++++++++++++
 win32ss/user/user32/controls/button.c | 11 ++++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/dll/win32/comctl32/button.c b/dll/win32/comctl32/button.c
index 1d7431d0b16..aacb96f7a29 100644
--- a/dll/win32/comctl32/button.c
+++ b/dll/win32/comctl32/button.c
@@ -785,7 +785,11 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT 
uMsg, WPARAM wParam, L
                 SendMessageW( hWnd, BM_SETCHECK, !(infoPtr->state & 
BST_CHECKED), 0 );
                 break;
             case BS_AUTORADIOBUTTON:
+#ifdef __REACTOS__
+                BUTTON_CheckAutoRadioButton( hWnd );
+#else
                 SendMessageW( hWnd, BM_SETCHECK, TRUE, 0 );
+#endif
                 break;
             case BS_AUTO3STATE:
                 SendMessageW( hWnd, BM_SETCHECK, (infoPtr->state & 
BST_INDETERMINATE) ? 0 :
@@ -1118,8 +1122,10 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, 
UINT uMsg, WPARAM wParam, L
             infoPtr->state = (infoPtr->state & ~3) | wParam;
             InvalidateRect( hWnd, NULL, FALSE );
         }
+#ifndef __REACTOS__
         if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BST_CHECKED) && 
(style & WS_CHILD))
             BUTTON_CheckAutoRadioButton( hWnd );
+#endif
         break;
 
     case BM_GETSTATE:
@@ -1645,13 +1651,22 @@ static void BUTTON_CheckAutoRadioButton( HWND hwnd )
 
     parent = GetParent(hwnd);
     /* make sure that starting control is not disabled or invisible */
+#ifdef __REACTOS__
+    start = sibling = hwnd;
+#else
     start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );
+#endif
     do
     {
         if (!sibling) break;
+#ifdef __REACTOS__
+        if (SendMessageW( sibling, WM_GETDLGCODE, 0, 0 ) == (DLGC_BUTTON | 
DLGC_RADIOBUTTON))
+            SendMessageW( sibling, BM_SETCHECK, sibling == hwnd ? BST_CHECKED 
: BST_UNCHECKED, 0 );
+#else
         if ((hwnd != sibling) &&
             ((GetWindowLongW( sibling, GWL_STYLE) & BS_TYPEMASK) == 
BS_AUTORADIOBUTTON))
             SendMessageW( sibling, BM_SETCHECK, BST_UNCHECKED, 0 );
+#endif
         sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
     } while (sibling != start);
 }
diff --git a/win32ss/user/user32/controls/button.c 
b/win32ss/user/user32/controls/button.c
index 6e7d70e77e0..a9afe494c7a 100644
--- a/win32ss/user/user32/controls/button.c
+++ b/win32ss/user/user32/controls/button.c
@@ -412,7 +412,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
                 SendMessageW( hWnd, BM_SETCHECK, !(state & BST_CHECKED), 0 );
                 break;
             case BS_AUTORADIOBUTTON:
-                SendMessageW( hWnd, BM_SETCHECK, TRUE, 0 );
+                BUTTON_CheckAutoRadioButton( hWnd );
                 break;
             case BS_AUTO3STATE:
                 SendMessageW( hWnd, BM_SETCHECK,
@@ -624,8 +624,6 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
             set_button_state( hWnd, (state & ~3) | wParam );
             paint_button( hWnd, btn_type, ODA_SELECT );
         }
-        if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BST_CHECKED) && 
(style & WS_CHILD))
-            BUTTON_CheckAutoRadioButton( hWnd );
         break;
 
     case BM_GETSTATE:
@@ -1188,13 +1186,12 @@ static void BUTTON_CheckAutoRadioButton( HWND hwnd )
 
     parent = GetParent(hwnd);
     /* make sure that starting control is not disabled or invisible */
-    start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );
+    start = sibling = hwnd;
     do
     {
         if (!sibling) break;
-        if ((hwnd != sibling) &&
-            ((GetWindowLongPtrW( sibling, GWL_STYLE) & BS_TYPEMASK) == 
BS_AUTORADIOBUTTON))
-            SendMessageW( sibling, BM_SETCHECK, BST_UNCHECKED, 0 );
+        if (SendMessageW( sibling, WM_GETDLGCODE, 0, 0 ) == (DLGC_BUTTON | 
DLGC_RADIOBUTTON))
+            SendMessageW( sibling, BM_SETCHECK, sibling == hwnd ? BST_CHECKED 
: BST_UNCHECKED, 0 );
         sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
     } while (sibling != start);
 }

Reply via email to