From 52373b2df3dd49f849e7c08d976b931241318b1d Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Fri, 24 Sep 2004 00:22:13 +0000 Subject: [PATCH] MenuItemFromPoint shouldn't crash if there's no menu. --- dlls/user/menu.c | 9 ++++----- include/winuser.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dlls/user/menu.c b/dlls/user/menu.c index f59b68be747..b88fc51de52 100644 --- a/dlls/user/menu.c +++ b/dlls/user/menu.c @@ -633,7 +633,7 @@ static void MENU_FreeItemData( MENUITEM* item ) * not work for child windows and therefore should not be called for * an arbitrary system menu. */ -static MENUITEM *MENU_FindItemByCoords( POPUPMENU *menu, +static MENUITEM *MENU_FindItemByCoords( const POPUPMENU *menu, POINT pt, UINT *pos ) { MENUITEM *item; @@ -4500,15 +4500,14 @@ DWORD WINAPI GetMenuContextHelpId( HMENU hMenu ) /********************************************************************** * MenuItemFromPoint (USER32.@) */ -UINT WINAPI MenuItemFromPoint(HWND hWnd, HMENU hMenu, POINT ptScreen) +INT WINAPI MenuItemFromPoint(HWND hWnd, HMENU hMenu, POINT ptScreen) { POPUPMENU *menu = MENU_GetMenu(hMenu); UINT pos; - MENUITEM *item; /*FIXME: Do we have to handle hWnd here? */ - item = MENU_FindItemByCoords(menu, ptScreen, &pos); - + if (!menu) return -1; + if (!MENU_FindItemByCoords(menu, ptScreen, &pos)) return -1; return pos; } diff --git a/include/winuser.h b/include/winuser.h index 1585f2aa023..1ec72c40731 100644 --- a/include/winuser.h +++ b/include/winuser.h @@ -4336,7 +4336,7 @@ UINT WINAPI MapVirtualKeyExW(UINT,UINT,HKL); #define MapVirtualKeyEx WINELIB_NAME_AW(MapVirtualKeyEx) BOOL WINAPI MapDialogRect(HWND,LPRECT); INT WINAPI MapWindowPoints(HWND,HWND,LPPOINT,UINT); -UINT WINAPI MenuItemFromPoint(HWND,HMENU,POINT); +INT WINAPI MenuItemFromPoint(HWND,HMENU,POINT); BOOL WINAPI MessageBeep(UINT); INT WINAPI MessageBoxA(HWND,LPCSTR,LPCSTR,UINT); INT WINAPI MessageBoxW(HWND,LPCWSTR,LPCWSTR,UINT);