Jacek Caban : win32u: Move GetMenuState implementation from user32.

Alexandre Julliard julliard at winehq.org
Mon May 2 16:02:10 CDT 2022


Module: wine
Branch: master
Commit: 1899cd2a9eebbadf5bca45f601b850ef0d8ce308
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1899cd2a9eebbadf5bca45f601b850ef0d8ce308

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Apr 14 16:20:38 2022 +0200

win32u: Move GetMenuState implementation from user32.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/menu.c | 32 ++------------------------------
 dlls/win32u/menu.c | 34 ++++++++++++++++++++++++++++++++++
 include/ntuser.h   |  2 ++
 3 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 5101a095966..e81fc086918 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -3687,37 +3687,9 @@ BOOL WINAPI HiliteMenuItem( HWND hWnd, HMENU hMenu, UINT wItemID,
 /**********************************************************************
  *         GetMenuState    (USER32.@)
  */
-UINT WINAPI GetMenuState( HMENU hMenu, UINT wItemID, UINT wFlags )
+UINT WINAPI GetMenuState( HMENU menu, UINT item, UINT flags )
 {
-    POPUPMENU *menu;
-    UINT state, pos;
-    MENUITEM *item;
-
-    TRACE("(menu=%p, id=%04x, flags=%04x);\n", hMenu, wItemID, wFlags);
-
-    if (!(menu = find_menu_item(hMenu, wItemID, wFlags, &pos)))
-        return -1;
-
-    item = &menu->items[pos];
-    debug_print_menuitem ("  item: ", item, "");
-    if (item->fType & MF_POPUP)
-    {
-        POPUPMENU *submenu = grab_menu_ptr(item->hSubMenu);
-        if (submenu)
-            state = (submenu->nItems << 8) | ((item->fState | item->fType) & 0xff);
-        else
-            state = -1;
-        release_menu_ptr(submenu);
-    }
-    else
-    {
-	/* We used to (from way back then) mask the result to 0xff.  */
-	/* I don't know why and it seems wrong as the documented */
-	/* return flag MF_SEPARATOR is outside that mask.  */
-        state = (item->fType | item->fState);
-    }
-    release_menu_ptr(menu);
-    return state;
+    return NtUserThunkedMenuItemInfo( menu, item, flags, NtUserGetMenuState, NULL, NULL );
 }
 
 
diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
index 0d7127fb4c6..0f918a4762d 100644
--- a/dlls/win32u/menu.c
+++ b/dlls/win32u/menu.c
@@ -772,6 +772,37 @@ static BOOL set_menu_item_info( MENUITEM *menu, const MENUITEMINFOW *info )
     return TRUE;
 }
 
+/* see GetMenuState */
+static UINT get_menu_state( HMENU handle, UINT item_id, UINT flags )
+{
+    POPUPMENU *menu;
+    UINT state, pos;
+    MENUITEM *item;
+
+    TRACE( "(menu=%p, id=%04x, flags=%04x);\n", handle, item_id, flags );
+
+    if (!(menu = find_menu_item( handle, item_id, flags, &pos )))
+        return -1;
+
+    item = &menu->items[pos];
+    TRACE( "  item: %s\n", debugstr_menuitem( item ));
+    if (item->fType & MF_POPUP)
+    {
+        POPUPMENU *submenu = grab_menu_ptr( item->hSubMenu );
+        if (submenu)
+            state = (submenu->nItems << 8) | ((item->fState | item->fType) & 0xff);
+        else
+            state = -1;
+        release_menu_ptr( submenu );
+    }
+    else
+    {
+        state = item->fType | item->fState;
+    }
+    release_menu_ptr(menu);
+    return state;
+}
+
 /**********************************************************************
  *           NtUserThunkedMenuItemInfo    (win32u.@)
  */
@@ -822,6 +853,9 @@ UINT WINAPI NtUserThunkedMenuItemInfo( HMENU handle, UINT pos, UINT flags, UINT
         release_menu_ptr(menu);
         break;
 
+    case NtUserGetMenuState:
+        return get_menu_state( handle, pos, flags );
+
     default:
         FIXME( "unsupported method %u\n", method );
         return FALSE;
diff --git a/include/ntuser.h b/include/ntuser.h
index 75b9ba7b73c..75c16e412c0 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -183,6 +183,8 @@ enum
 {
     NtUserSetMenuItemInfo,
     NtUserInsertMenuItem,
+    /* Wine extensions */
+    NtUserGetMenuState,
 };
 
 struct send_message_timeout_params




More information about the wine-cvs mailing list