Commit a4d6198a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move NtUserCheckMenuItem implementation from user32.

parent 72d53fda
......@@ -457,7 +457,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf);
if (ci->child[i] == ci->hwndActiveChild)
CheckMenuItem(ci->hWindowMenu, id, MF_CHECKED);
NtUserCheckMenuItem(ci->hWindowMenu, id, MF_CHECKED);
}
else
TRACE("MDI child %p is not visible, skipping\n", ci->child[i]);
......
......@@ -58,27 +58,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(menu);
WINE_DECLARE_DEBUG_CHANNEL(accel);
/* Menu item structure */
typedef struct menu_item {
/* ----------- MENUITEMINFO Stuff ----------- */
UINT fType; /* Item type. */
UINT fState; /* Item state. */
UINT_PTR wID; /* Item id. */
HMENU hSubMenu; /* Pop-up menu. */
HBITMAP hCheckBit; /* Bitmap when checked. */
HBITMAP hUnCheckBit; /* Bitmap when unchecked. */
LPWSTR text; /* Item text. */
ULONG_PTR dwItemData; /* Application defined. */
LPWSTR dwTypeData; /* depends on fMask */
HBITMAP hbmpItem; /* bitmap */
/* ----------- Wine stuff ----------- */
RECT rect; /* Item area (relative to the items_rect).
* See MENU_AdjustMenuItemRect(). */
UINT xTab; /* X position of text after Tab */
SIZE bmpsize; /* size needed for the HBMMENU_CALLBACK
* bitmap */
} MENUITEM;
/* internal flags for menu tracking */
#define TF_ENDMENU 0x10000
......@@ -3665,28 +3644,6 @@ BOOL WINAPI ChangeMenuW( HMENU hMenu, UINT pos, LPCWSTR data,
}
/*******************************************************************
* CheckMenuItem (USER32.@)
*/
DWORD WINAPI CheckMenuItem( HMENU hMenu, UINT id, UINT flags )
{
POPUPMENU *menu;
MENUITEM *item;
DWORD ret;
UINT pos;
if (!(menu = find_menu_item(hMenu, id, flags, &pos)))
return -1;
item = &menu->items[pos];
ret = item->fState & MF_CHECKED;
if (flags & MF_CHECKED) item->fState |= MF_CHECKED;
else item->fState &= ~MF_CHECKED;
release_menu_ptr(menu);
return ret;
}
/**********************************************************************
* EnableMenuItem (USER32.@)
*/
......
......@@ -63,7 +63,7 @@
@ stdcall -import CharUpperBuffW(wstr long)
@ stdcall -import CharUpperW(wstr)
@ stdcall CheckDlgButton(long long long)
@ stdcall CheckMenuItem(long long long)
@ stdcall CheckMenuItem(long long long) NtUserCheckMenuItem
@ stdcall CheckMenuRadioItem(long long long long long)
@ stdcall CheckRadioButton(long long long long)
@ stdcall ChildWindowFromPoint(long int64)
......
......@@ -110,6 +110,91 @@ BOOL WINAPI NtUserDestroyAcceleratorTable( HACCEL handle )
return TRUE;
}
static POPUPMENU *grab_menu_ptr( HMENU handle )
{
POPUPMENU *menu = get_user_handle_ptr( handle, NTUSER_OBJ_MENU );
if (menu == OBJ_OTHER_PROCESS)
{
WARN( "other process menu %p\n", handle );
return NULL;
}
if (menu)
menu->refcount++;
else
WARN( "invalid menu handle=%p\n", handle );
return menu;
}
static void release_menu_ptr( POPUPMENU *menu )
{
if (menu)
{
menu->refcount--;
release_user_handle_ptr( menu );
}
}
static POPUPMENU *find_menu_item( HMENU handle, UINT id, UINT flags, UINT *pos )
{
UINT fallback_pos = ~0u, i;
POPUPMENU *menu;
menu = grab_menu_ptr( handle );
if (!menu)
return NULL;
if (flags & MF_BYPOSITION)
{
if (id >= menu->nItems)
{
release_menu_ptr( menu );
return NULL;
}
if (pos) *pos = id;
return menu;
}
else
{
MENUITEM *item = menu->items;
for (i = 0; i < menu->nItems; i++, item++)
{
if (item->fType & MF_POPUP)
{
POPUPMENU *submenu = find_menu_item( item->hSubMenu, id, flags, pos );
if (submenu)
{
release_menu_ptr( menu );
return submenu;
}
else if (item->wID == id)
{
/* fallback to this item if nothing else found */
fallback_pos = i;
}
}
else if (item->wID == id)
{
if (pos) *pos = i;
return menu;
}
}
}
if (fallback_pos != ~0u)
*pos = fallback_pos;
else
{
release_menu_ptr( menu );
menu = NULL;
}
return menu;
}
/* see GetMenu */
HMENU get_menu( HWND hwnd )
{
......@@ -166,3 +251,24 @@ BOOL WINAPI NtUserSetSystemMenu( HWND hwnd, HMENU menu )
{
return user_callbacks && user_callbacks->pSetSystemMenu( hwnd, menu );
}
/*******************************************************************
* NtUserCheckMenuItem (win32u.@)
*/
DWORD WINAPI NtUserCheckMenuItem( HMENU handle, UINT id, UINT flags )
{
POPUPMENU *menu;
MENUITEM *item;
DWORD ret;
UINT pos;
if (!(menu = find_menu_item(handle, id, flags, &pos)))
return -1;
item = &menu->items[pos];
ret = item->fState & MF_CHECKED;
if (flags & MF_CHECKED) item->fState |= MF_CHECKED;
else item->fState &= ~MF_CHECKED;
release_menu_ptr(menu);
return ret;
}
......@@ -200,9 +200,29 @@ enum builtin_winprocs
NB_BUILTIN_AW_WINPROCS = WINPROC_DESKTOP
};
struct menu_item;
/* FIXME: make it private to menu.c */
/* Menu item structure */
typedef struct menu_item
{
/* ----------- MENUITEMINFO Stuff ----------- */
UINT fType; /* Item type. */
UINT fState; /* Item state. */
UINT_PTR wID; /* Item id. */
HMENU hSubMenu; /* Pop-up menu. */
HBITMAP hCheckBit; /* Bitmap when checked. */
HBITMAP hUnCheckBit; /* Bitmap when unchecked. */
LPWSTR text; /* Item text. */
ULONG_PTR dwItemData; /* Application defined. */
LPWSTR dwTypeData; /* depends on fMask */
HBITMAP hbmpItem; /* bitmap */
/* ----------- Wine stuff ----------- */
RECT rect; /* Item area (relative to the items_rect),
* see MENU_AdjustMenuItemRect(). */
UINT xTab; /* X position of text after Tab */
SIZE bmpsize; /* size needed for the HBMMENU_CALLBACK bitmap */
} MENUITEM;
typedef struct
{
struct user_object obj;
......
......@@ -106,6 +106,7 @@ static void * const syscalls[] =
NtUserAddClipboardFormatListener,
NtUserAttachThreadInput,
NtUserBuildHwndList,
NtUserCheckMenuItem,
NtUserChildWindowFromPointEx,
NtUserCloseDesktop,
NtUserCloseWindowStation,
......
......@@ -786,7 +786,7 @@
@ stdcall NtUserChangeDisplaySettings(ptr ptr long long ptr)
@ stub NtUserChangeWindowMessageFilterEx
@ stub NtUserCheckAccessForIntegrityLevel
@ stub NtUserCheckMenuItem
@ stdcall -syscall NtUserCheckMenuItem(long long long)
@ stub NtUserCheckProcessForClipboardAccess
@ stub NtUserCheckProcessSession
@ stub NtUserCheckWindowThreadDesktop
......
......@@ -93,6 +93,7 @@
SYSCALL_ENTRY( NtUserAddClipboardFormatListener ) \
SYSCALL_ENTRY( NtUserAttachThreadInput ) \
SYSCALL_ENTRY( NtUserBuildHwndList ) \
SYSCALL_ENTRY( NtUserCheckMenuItem ) \
SYSCALL_ENTRY( NtUserChildWindowFromPointEx ) \
SYSCALL_ENTRY( NtUserCloseDesktop ) \
SYSCALL_ENTRY( NtUserCloseWindowStation ) \
......
......@@ -616,3 +616,12 @@ NTSTATUS WINAPI wow64_NtUserDestroyAcceleratorTable( UINT *args )
return NtUserDestroyAcceleratorTable( handle );
}
NTSTATUS WINAPI wow64_NtUserCheckMenuItem( UINT *args )
{
HMENU handle = get_handle( &args );
UINT id = get_ulong( &args );
UINT flags = get_ulong( &args );
return NtUserCheckMenuItem( handle, id, flags );
}
......@@ -403,6 +403,7 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code );
ULONG_PTR WINAPI NtUserCallTwoParam( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code );
LONG WINAPI NtUserChangeDisplaySettings( UNICODE_STRING *devname, DEVMODEW *devmode, HWND hwnd,
DWORD flags, void *lparam );
DWORD WINAPI NtUserCheckMenuItem( HMENU handle, UINT id, UINT flags );
HWND WINAPI NtUserChildWindowFromPointEx( HWND parent, LONG x, LONG y, UINT flags );
BOOL WINAPI NtUserClipCursor( const RECT *rect );
BOOL WINAPI NtUserCloseClipboard(void);
......
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