Commit 9b1ea63b authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

user32: Make GetMenuItemInfo tests pass under Wine.

- Change menu item search algorithm to recurse into a submenu first. - Fallback to a found submenu if nothing else was found.
parent 04f547dc
......@@ -529,6 +529,7 @@ static UINT MENU_GetStartOfPrevColumn(
static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
{
POPUPMENU *menu;
MENUITEM *fallback = NULL;
UINT i;
if ((*hmenu == (HMENU)0xffff) || (!(menu = MENU_GetMenu(*hmenu)))) return NULL;
......@@ -542,12 +543,7 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
MENUITEM *item = menu->items;
for (i = 0; i < menu->nItems; i++, item++)
{
if (item->wID == *nPos)
{
*nPos = i;
return item;
}
else if (item->fType & MF_POPUP)
if (item->fType & MF_POPUP)
{
HMENU hsubmenu = item->hSubMenu;
MENUITEM *subitem = MENU_FindItem( &hsubmenu, nPos, wFlags );
......@@ -556,10 +552,17 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
*hmenu = hsubmenu;
return subitem;
}
if ((UINT_PTR)item->hSubMenu == *nPos)
fallback = item; /* fallback to this item if nothing else found */
}
else if (item->wID == *nPos)
{
*nPos = i;
return item;
}
}
}
return NULL;
return fallback;
}
/***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment