Jacek Caban : user32: Reimplement GetMenuStringW on top of NtUserThunkedMenuItemInfo.

Alexandre Julliard julliard at winehq.org
Tue Jun 21 15:45:24 CDT 2022


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Jun 21 13:19:44 2022 +0200

user32: Reimplement GetMenuStringW on top of NtUserThunkedMenuItemInfo.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>

---

 dlls/user32/menu.c | 41 +++++++++++------------------------------
 1 file changed, 11 insertions(+), 30 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 29a266d2312..434353e8892 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -498,39 +498,20 @@ INT WINAPI GetMenuStringA( HMENU menu, UINT item, char *str, INT count, UINT fla
 /*******************************************************************
  *         GetMenuStringW    (USER32.@)
  */
-INT WINAPI GetMenuStringW( HMENU hMenu, UINT wItemID,
-                               LPWSTR str, INT nMaxSiz, UINT wFlags )
+INT WINAPI GetMenuStringW( HMENU menu, UINT item, WCHAR *str, INT count, UINT flags )
 {
-    POPUPMENU *menu;
-    MENUITEM *item;
-    UINT pos;
-    INT ret;
-
-    TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags );
-    if (str && nMaxSiz) str[0] = '\0';
-
-    if (!(menu = find_menu_item(hMenu, wItemID, wFlags, &pos)))
-    {
-        SetLastError( ERROR_MENU_ITEM_NOT_FOUND);
-        return 0;
-    }
-    item = &menu->items[pos];
+    MENUITEMINFOW info;
+    int ret;
 
-    if (!str || !nMaxSiz)
-        ret = item->text ? lstrlenW(item->text) : 0;
-    else if (!item->text)
-    {
-        str[0] = 0;
-        ret = 0;
-    }
-    else
-    {
-        lstrcpynW( str, item->text, nMaxSiz );
-        ret = lstrlenW(str);
-    }
-    release_menu_ptr(menu);
+    TRACE( "menu=%p item=%04x ptr=%p len=%d flags=%04x\n", menu, item, str, count, flags );
 
-    TRACE("returning %s\n", debugstr_w(str));
+    info.cbSize = sizeof(info);
+    info.fMask = MIIM_STRING;
+    info.dwTypeData = str;
+    info.cch = count;
+    ret = NtUserThunkedMenuItemInfo( menu, item, flags, NtUserGetMenuItemInfoW, &info, NULL );
+    if (ret) ret = info.cch;
+    TRACE( "returning %s %d\n", debugstr_w( str ), ret );
     return ret;
 }
 




More information about the wine-cvs mailing list