win32u: Move GetMenuState implementation from user32.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-04-14 16:20:38 +02:00 committed by Alexandre Julliard
parent d366ef515d
commit 1899cd2a9e
3 changed files with 38 additions and 30 deletions

View File

@ -3687,37 +3687,9 @@ BOOL WINAPI HiliteMenuItem( HWND hWnd, HMENU hMenu, UINT wItemID,
/**********************************************************************
* GetMenuState (USER32.@)
*/
UINT WINAPI GetMenuState( HMENU hMenu, UINT wItemID, UINT wFlags )
UINT WINAPI GetMenuState( HMENU menu, UINT item, UINT flags )
{
POPUPMENU *menu;
UINT state, pos;
MENUITEM *item;
TRACE("(menu=%p, id=%04x, flags=%04x);\n", hMenu, wItemID, wFlags);
if (!(menu = find_menu_item(hMenu, wItemID, wFlags, &pos)))
return -1;
item = &menu->items[pos];
debug_print_menuitem (" item: ", item, "");
if (item->fType & MF_POPUP)
{
POPUPMENU *submenu = grab_menu_ptr(item->hSubMenu);
if (submenu)
state = (submenu->nItems << 8) | ((item->fState | item->fType) & 0xff);
else
state = -1;
release_menu_ptr(submenu);
}
else
{
/* We used to (from way back then) mask the result to 0xff. */
/* I don't know why and it seems wrong as the documented */
/* return flag MF_SEPARATOR is outside that mask. */
state = (item->fType | item->fState);
}
release_menu_ptr(menu);
return state;
return NtUserThunkedMenuItemInfo( menu, item, flags, NtUserGetMenuState, NULL, NULL );
}

View File

@ -772,6 +772,37 @@ static BOOL set_menu_item_info( MENUITEM *menu, const MENUITEMINFOW *info )
return TRUE;
}
/* see GetMenuState */
static UINT get_menu_state( HMENU handle, UINT item_id, UINT flags )
{
POPUPMENU *menu;
UINT state, pos;
MENUITEM *item;
TRACE( "(menu=%p, id=%04x, flags=%04x);\n", handle, item_id, flags );
if (!(menu = find_menu_item( handle, item_id, flags, &pos )))
return -1;
item = &menu->items[pos];
TRACE( " item: %s\n", debugstr_menuitem( item ));
if (item->fType & MF_POPUP)
{
POPUPMENU *submenu = grab_menu_ptr( item->hSubMenu );
if (submenu)
state = (submenu->nItems << 8) | ((item->fState | item->fType) & 0xff);
else
state = -1;
release_menu_ptr( submenu );
}
else
{
state = item->fType | item->fState;
}
release_menu_ptr(menu);
return state;
}
/**********************************************************************
* NtUserThunkedMenuItemInfo (win32u.@)
*/
@ -822,6 +853,9 @@ UINT WINAPI NtUserThunkedMenuItemInfo( HMENU handle, UINT pos, UINT flags, UINT
release_menu_ptr(menu);
break;
case NtUserGetMenuState:
return get_menu_state( handle, pos, flags );
default:
FIXME( "unsupported method %u\n", method );
return FALSE;

View File

@ -183,6 +183,8 @@ enum
{
NtUserSetMenuItemInfo,
NtUserInsertMenuItem,
/* Wine extensions */
NtUserGetMenuState,
};
struct send_message_timeout_params