[PATCH 2/3] win32u: Move CheckMenuRadioItem implementation from user32.

Jacek Caban wine at gitlab.winehq.org
Fri Jun 24 07:31:51 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

---
 dlls/user32/menu.c | 49 +++++-----------------------------------------
 dlls/win32u/menu.c | 45 ++++++++++++++++++++++++++++++++++++++++++
 include/ntuser.h   |  1 +
 3 files changed, 51 insertions(+), 44 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 342ee08a89b..043af437356 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -1098,51 +1098,12 @@ BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
 /**********************************************************************
  *		CheckMenuRadioItem    (USER32.@)
  */
-
-BOOL WINAPI CheckMenuRadioItem(HMENU hMenu, UINT first, UINT last,
-    UINT check, UINT flags)
+BOOL WINAPI CheckMenuRadioItem( HMENU menu, UINT first, UINT last, UINT check, UINT flags )
 {
-    POPUPMENU *first_menu = NULL, *check_menu;
-    UINT i, check_pos;
-    BOOL done = FALSE;
-
-    for (i = first; i <= last; i++)
-    {
-        MENUITEM *item;
-
-        if (!(check_menu = find_menu_item(hMenu, i, flags, &check_pos)))
-            continue;
-
-        if (!first_menu)
-            first_menu = grab_menu_ptr(check_menu->obj.handle);
-
-        if (first_menu != check_menu)
-        {
-            release_menu_ptr(check_menu);
-            continue;
-        }
-
-        item = &check_menu->items[check_pos];
-        if (item->fType != MFT_SEPARATOR)
-        {
-            if (i == check)
-            {
-                item->fType |= MFT_RADIOCHECK;
-                item->fState |= MFS_CHECKED;
-                done = TRUE;
-            }
-            else
-            {
-                /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
-                item->fState &= ~MFS_CHECKED;
-            }
-        }
-
-        release_menu_ptr(check_menu);
-    }
-    release_menu_ptr(first_menu);
-
-    return done;
+    MENUITEMINFOW info; /* abuse to pass last and check */
+    info.cch = last;
+    info.fMask = check;
+    return NtUserThunkedMenuItemInfo( menu, first, flags, NtUserCheckMenuRadioItem, &info, NULL );
 }
 
 
diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
index eab97e58d39..4ba5b42ec9d 100644
--- a/dlls/win32u/menu.c
+++ b/dlls/win32u/menu.c
@@ -1109,6 +1109,48 @@ static BOOL get_menu_item_info( HMENU handle, UINT id, UINT flags, MENUITEMINFOW
     return TRUE;
 }
 
+static BOOL check_menu_radio_item( HMENU handle, UINT first, UINT last, UINT check, UINT flags )
+{
+    POPUPMENU *first_menu = NULL, *check_menu;
+    UINT i, check_pos;
+    BOOL done = FALSE;
+
+    for (i = first; i <= last; i++)
+    {
+        MENUITEM *item;
+
+        if (!(check_menu = find_menu_item( handle, i, flags, &check_pos ))) continue;
+        if (!first_menu) first_menu = grab_menu_ptr( check_menu->obj.handle );
+
+        if (first_menu != check_menu)
+        {
+            release_menu_ptr(check_menu);
+            continue;
+        }
+
+        item = &check_menu->items[check_pos];
+        if (item->fType != MFT_SEPARATOR)
+        {
+            if (i == check)
+            {
+                item->fType |= MFT_RADIOCHECK;
+                item->fState |= MFS_CHECKED;
+                done = TRUE;
+            }
+            else
+            {
+                /* Windows does not remove MFT_RADIOCHECK */
+                item->fState &= ~MFS_CHECKED;
+            }
+        }
+
+        release_menu_ptr( check_menu );
+    }
+
+    release_menu_ptr( first_menu );
+    return done;
+}
+
 /**********************************************************************
  *           NtUserThunkedMenuItemInfo    (win32u.@)
  */
@@ -1121,6 +1163,9 @@ UINT WINAPI NtUserThunkedMenuItemInfo( HMENU handle, UINT pos, UINT flags, UINT
 
     switch (method)
     {
+    case NtUserCheckMenuRadioItem:
+        return check_menu_radio_item( handle, pos, info->cch, info->fMask, flags );
+
     case NtUserGetMenuItemID:
         if (!(menu = find_menu_item( handle, pos, flags, &i ))) return -1;
         ret = menu->items[i].fType & MF_POPUP ? -1 : menu->items[i].wID;
diff --git a/include/ntuser.h b/include/ntuser.h
index 41b328376a9..e15345bb7d6 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -224,6 +224,7 @@ enum
     NtUserSetMenuItemInfo,
     NtUserInsertMenuItem,
     /* Wine extensions */
+    NtUserCheckMenuRadioItem,
     NtUserGetMenuItemID,
     NtUserGetMenuItemInfoA,
     NtUserGetMenuItemInfoW,
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/311



More information about the wine-devel mailing list