Index: reactos/win32ss/user/user32/controls/button.c =================================================================== --- reactos/win32ss/user/user32/controls/button.c (revision 73458) +++ reactos/win32ss/user/user32/controls/button.c (working copy) @@ -3,6 +3,7 @@ * Copyright (C) 1993 Johannes Ruscheinski * Copyright (C) 1993 David Metcalfe * Copyright (C) 1994 Alexandre Julliard + * Copyright (C) 2016 Katayama Hirofumi MZ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1169,19 +1170,86 @@ */ static void BUTTON_CheckAutoRadioButton( HWND hwnd ) { - HWND parent, sibling, start; + HWND parent, top, bottom, first, last, sibling; + WCHAR szClass[10]; // enough size for checking if "BUTTON" or not + DWORD dwStyle; + if (!IsWindowVisible(hwnd) || !IsWindowEnabled(hwnd)) + return; + parent = GetParent(hwnd); - /* make sure that starting control is not disabled or invisible */ - start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE ); - do + top = GetNextDlgTabItem(parent, NULL, FALSE); + bottom = GetNextDlgTabItem(parent, NULL, TRUE); + + /* scan backward from hwnd */ + first = hwnd; + for (;;) { - if (!sibling) break; - if ((hwnd != sibling) && - ((GetWindowLongPtrW( sibling, GWL_STYLE) & BS_TYPEMASK) == BS_AUTORADIOBUTTON)) - SendMessageW( sibling, BM_SETCHECK, BST_UNCHECKED, 0 ); - sibling = GetNextDlgGroupItem( parent, sibling, FALSE ); - } while (sibling != start); + sibling = GetNextDlgTabItem(parent, first, TRUE); + if (sibling == hwnd || sibling == NULL || sibling == bottom) + break; + + dwStyle = GetWindowLongW(sibling, GWL_STYLE); + if ((dwStyle & BS_TYPEMASK) != BS_AUTORADIOBUTTON && + (dwStyle & BS_TYPEMASK) != BS_RADIOBUTTON) + { + break; + } + + GetClassNameW(sibling, szClass, _countof(szClass)); + if (lstrcmpiW(szClass, buttonW) != 0) + break; + + first = sibling; + if (first == top || (dwStyle & WS_GROUP)) + break; + } + + /* scan forward from hwnd */ + last = hwnd; + for (;;) + { + sibling = GetNextDlgTabItem(parent, last, FALSE); + if (sibling == hwnd || sibling == NULL || sibling == top) + break; + + dwStyle = GetWindowLongW(sibling, GWL_STYLE); + if (dwStyle & WS_GROUP) + break; + + if ((dwStyle & BS_TYPEMASK) != BS_AUTORADIOBUTTON && + (dwStyle & BS_TYPEMASK) != BS_RADIOBUTTON) + { + break; + } + + GetClassNameW(sibling, szClass, _countof(szClass)); + if (lstrcmpiW(szClass, buttonW) != 0) + break; + + last = sibling; + if (last == bottom) + break; + } + + /* uncheck from first to last */ + while (first != last && first != NULL) + { + if (first != hwnd) + { + dwStyle = GetWindowLongW(first, GWL_STYLE); + if ((dwStyle & BS_TYPEMASK) == BS_AUTORADIOBUTTON) + PostMessageW(first, BM_SETCHECK, BST_UNCHECKED, 0); + } + first = GetNextDlgTabItem(parent, first, FALSE); + } + /* last */ + if (first != hwnd && first != NULL) + { + dwStyle = GetWindowLongW(first, GWL_STYLE); + if ((dwStyle & BS_TYPEMASK) == BS_AUTORADIOBUTTON) + PostMessageW(first, BM_SETCHECK, BST_UNCHECKED, 0); + } }