Jacek Caban : user32: Perform Unicode conversion in SetMenuItemInfoA.

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


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Apr 12 21:46:32 2022 +0200

user32: Perform Unicode conversion in SetMenuItemInfoA.

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

---

 dlls/user32/menu.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 6336355691d..14ed4cb10e2 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -4824,6 +4824,7 @@ static BOOL MENU_NormalizeMenuItemInfoStruct( const MENUITEMINFOW *pmii_in,
 BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos,
                                  const MENUITEMINFOA *lpmii)
 {
+    WCHAR *strW = NULL;
     MENUITEMINFOW mii;
     POPUPMENU *menu;
     UINT pos;
@@ -4833,14 +4834,25 @@ BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos,
 
     if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &mii )) return FALSE;
 
+    if ((mii.fMask & MIIM_STRING) && mii.dwTypeData)
+    {
+        const char *str = (const char *)mii.dwTypeData;
+        UINT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
+        if (!(strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return FALSE;
+        MultiByteToWideChar( CP_ACP, 0, str, -1, strW, len );
+        mii.dwTypeData = strW;
+    }
+
     if (!(menu = find_menu_item(hmenu, item, bypos ? MF_BYPOSITION : 0, &pos)))
     {
         /* workaround for Word 95: pretend that SC_TASKLIST item exists */
+        HeapFree( GetProcessHeap(), 0, strW );
         if (item == SC_TASKLIST && !bypos) return TRUE;
         return FALSE;
     }
-    ret = SetMenuItemInfo_common(&menu->items[pos], &mii, FALSE);
+    ret = SetMenuItemInfo_common(&menu->items[pos], &mii, TRUE);
     release_menu_ptr(menu);
+    HeapFree( GetProcessHeap(), 0, strW );
     return ret;
 }
 




More information about the wine-cvs mailing list