From 64823b26943f03971d6a0106a23a9a58e0a566ed Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 8 Sep 2012 06:09:19 +0000 Subject: [PATCH] [Win32SS] - HAX: Fix menu test crash! - Contract be damned. This number 2 on my list to move server side! svn path=/trunk/; revision=57251 --- reactos/win32ss/user/ntuser/menu.c | 15 +++++++++++++++ reactos/win32ss/user/user32/user32.spec | 2 +- reactos/win32ss/user/user32/windows/menu.c | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/reactos/win32ss/user/ntuser/menu.c b/reactos/win32ss/user/ntuser/menu.c index 45d33b3e0f6..881340d8e3b 100644 --- a/reactos/win32ss/user/ntuser/menu.c +++ b/reactos/win32ss/user/ntuser/menu.c @@ -1814,14 +1814,29 @@ NtUserGetMenuBarInfo( } if (MenuObject->MenuInfo.FocusedItem != NO_SELECTED_ITEM) kmbi.fBarFocused = TRUE; + + if (MenuObject->MenuItemList) + { SubMenuObject = UserGetMenuObject(MenuObject->MenuItemList->hSubMenu); if(SubMenuObject) kmbi.hwndMenu = SubMenuObject->MenuInfo.Wnd; + } TRACE("OBJID_MENU, idItem = %d\n",idItem); break; } case OBJID_CLIENT: { PMENU_OBJECT SubMenuObject, XSubMenuObject; + HMENU hMenuChk; + // Windows does this! Wine checks for Atom and uses GetWindowLongPtrW. + hMenuChk = (HMENU)co_IntSendMessage(hwnd, MN_GETHMENU, 0, 0); + + if (!(MenuObject = UserGetMenuObject(hMenuChk))) + { + ERR("Window does not have a Popup Menu!\n"); + EngSetLastError(ERROR_INVALID_MENU_HANDLE); + RETURN(FALSE); + } + SubMenuObject = UserGetMenuObject(MenuObject->MenuItemList->hSubMenu); if(SubMenuObject) kmbi.hMenu = SubMenuObject->MenuInfo.Self; else diff --git a/reactos/win32ss/user/user32/user32.spec b/reactos/win32ss/user/user32/user32.spec index 5a2ae820c0b..5b6ab0f7dad 100644 --- a/reactos/win32ss/user/user32/user32.spec +++ b/reactos/win32ss/user/user32/user32.spec @@ -302,7 +302,7 @@ @ stdcall GetLayeredWindowAttributes(long ptr ptr ptr) NtUserGetLayeredWindowAttributes @ stdcall GetListBoxInfo(long) NtUserGetListBoxInfo @ stdcall GetMenu(long) -@ stdcall GetMenuBarInfo(long long long ptr) NtUserGetMenuBarInfo +@ stdcall GetMenuBarInfo(long long long ptr) ; tempo haxzo NtUserGetMenuBarInfo @ stdcall GetMenuCheckMarkDimensions() @ stdcall GetMenuContextHelpId(long) @ stdcall GetMenuDefaultItem(long long long) diff --git a/reactos/win32ss/user/user32/windows/menu.c b/reactos/win32ss/user/user32/windows/menu.c index fe0a911329a..2f544a7abed 100644 --- a/reactos/win32ss/user/user32/windows/menu.c +++ b/reactos/win32ss/user/user32/windows/menu.c @@ -4216,6 +4216,26 @@ GetMenu(HWND hWnd) } +/* + * @implemented + */ +BOOL WINAPI GetMenuBarInfo( HWND hwnd, LONG idObject, LONG idItem, PMENUBARINFO pmbi ) +{ + BOOL Ret; + Ret = NtUserGetMenuBarInfo( hwnd, idObject, idItem, pmbi); + // Reason to move to server side!!!!! + if (!Ret) return Ret; + // EL HAXZO!!! + pmbi->fBarFocused = top_popup_hmenu == pmbi->hMenu; + if (!idItem) + { + pmbi->fFocused = pmbi->fBarFocused; + } + + return TRUE; +} + + /* * @implemented */