From: Jacek Caban jacek@codeweavers.com
--- dlls/user32/menu.c | 3 ++- dlls/user32/tests/menu.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index afbf4d2fcea..52dc6369e3a 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -489,7 +489,8 @@ static void MENU_mnu2mnuii( UINT flags, UINT_PTR id, LPCWSTR str, pmii->fMask |= MIIM_DATA; pmii->dwItemData = (ULONG_PTR) str; } - if( flags & MF_POPUP && MENU_GetMenu((HMENU)id)) { + if ((flags & MF_POPUP) && IsMenu( UlongToHandle( id ))) + { pmii->fMask |= MIIM_SUBMENU; pmii->hSubMenu = (HMENU)id; } diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c index c7a20e1b8e9..6862f13c6b1 100644 --- a/dlls/user32/tests/menu.c +++ b/dlls/user32/tests/menu.c @@ -3013,6 +3013,7 @@ static void test_InsertMenu(void) { MF_HELP, 1, MAKEINTRESOURCEA(1) } }; HMENU hmenu; + BOOL ret;
#define create_menu(a) create_menu_from_data((a), ARRAY_SIZE(a)) #define create_menuitem(a) create_menuitem_from_data((a), ARRAY_SIZE(a)) @@ -3054,6 +3055,16 @@ static void test_InsertMenu(void) #undef create_menu #undef create_menuitem #undef compare_menu + + hmenu = CreateMenu(); + + SetLastError(0xdeadbeef); + ret = InsertMenuW(hmenu, -1, MF_BYPOSITION | MF_POPUP, 0xdeadbeef, L"test"); + ok(ret && GetLastError() == ERROR_INVALID_MENU_HANDLE, + "InsertMenuW returned %x %lu\n", ret, GetLastError()); + ok(GetMenuItemCount(hmenu) == 1, "GetMenuItemCount() = %d\n", GetMenuItemCount(hmenu)); + + DestroyMenu(hmenu); }
static void test_menu_getmenuinfo(void)