Commit 9015ae59 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move NtUserSetMenu implemenetation from user32.

parent 19a2af27
......@@ -117,7 +117,6 @@ extern BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern ) DEC
extern HWND MENU_IsMenuActive(void) DECLSPEC_HIDDEN;
extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth,
INT orgX, INT orgY ) DECLSPEC_HIDDEN;
extern BOOL MENU_SetMenu(HWND, HMENU) DECLSPEC_HIDDEN;
extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt ) DECLSPEC_HIDDEN;
extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar ) DECLSPEC_HIDDEN;
extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd ) DECLSPEC_HIDDEN;
......
......@@ -357,7 +357,7 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
if (hmenuFrame)
{
SetMenu(hwndFrame, hmenuFrame);
NtUserSetMenu(hwndFrame, hmenuFrame);
if( hmenuFrame != ci->hFrameMenu )
{
HMENU oldFrameMenu = ci->hFrameMenu;
......
......@@ -4292,55 +4292,6 @@ BOOL WINAPI GetMenuBarInfo( HWND hwnd, LONG idObject, LONG idItem, PMENUBARINFO
return TRUE;
}
/**********************************************************************
* MENU_SetMenu
*
* Helper for SetMenu. Also called by WIN_CreateWindowEx to avoid the
* SetWindowPos call that would result if SetMenu were called directly.
*/
BOOL MENU_SetMenu( HWND hWnd, HMENU hMenu )
{
TRACE("(%p, %p);\n", hWnd, hMenu);
if (hMenu && !IsMenu(hMenu))
{
WARN("hMenu %p is not a menu handle\n", hMenu);
return FALSE;
}
if (is_win_menu_disallowed(hWnd))
return FALSE;
hWnd = WIN_GetFullHandle( hWnd );
if (GetCapture() == hWnd)
set_capture_window( 0, GUI_INMENUMODE, NULL ); /* release the capture */
if (hMenu)
{
POPUPMENU *menu;
if (!(menu = grab_menu_ptr(hMenu))) return FALSE;
menu->hWnd = hWnd;
menu->Height = 0; /* Make sure we recalculate the size */
release_menu_ptr(menu);
}
SetWindowLongPtrW( hWnd, GWLP_ID, (LONG_PTR)hMenu );
return TRUE;
}
/**********************************************************************
* SetMenu (USER32.@)
*/
BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu )
{
if(!MENU_SetMenu(hWnd, hMenu))
return FALSE;
NtUserSetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
return TRUE;
}
/**********************************************************************
* GetSubMenu (USER32.@)
......
......@@ -678,7 +678,7 @@
@ stdcall SetLastErrorEx(long long)
@ stdcall SetLayeredWindowAttributes(ptr long long long) NtUserSetLayeredWindowAttributes
@ stdcall SetLogonNotifyWindow(long long)
@ stdcall SetMenu(long long)
@ stdcall SetMenu(long long) NtUserSetMenu
@ stdcall SetMenuContextHelpId(long long) NtUserSetMenuContextHelpId
@ stdcall SetMenuDefaultItem(long long long)
@ stdcall SetMenuInfo(long ptr)
......
......@@ -176,7 +176,6 @@ static const struct user_callbacks user_funcs =
process_rawinput_message,
rawinput_device_get_usages,
register_builtin_classes,
MENU_SetMenu,
SCROLL_SetStandardScrollPainted,
unpack_dde_message,
register_imm,
......
......@@ -1197,6 +1197,7 @@ static struct unix_funcs unix_funcs =
NtUserSetCursorPos,
NtUserSetFocus,
NtUserSetLayeredWindowAttributes,
NtUserSetMenu,
NtUserSetParent,
NtUserSetSysColors,
NtUserSetWindowLong,
......
......@@ -1260,6 +1260,14 @@ HWND get_active_window(void)
return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndActive : 0;
}
/* see GetCapture */
HWND get_capture(void)
{
GUITHREADINFO info;
info.cbSize = sizeof(info);
return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndCapture : 0;
}
/* see GetFocus */
HWND get_focus(void)
{
......
......@@ -137,6 +137,20 @@ static void release_menu_ptr( POPUPMENU *menu )
}
}
/* see IsMenu */
static BOOL is_menu( HMENU handle )
{
POPUPMENU *menu;
BOOL is_menu;
menu = grab_menu_ptr( handle );
is_menu = menu != NULL;
release_menu_ptr( menu );
if (!is_menu) SetLastError( ERROR_INVALID_MENU_HANDLE );
return is_menu;
}
static POPUPMENU *find_menu_item( HMENU handle, UINT id, UINT flags, UINT *pos )
{
UINT fallback_pos = ~0u, i;
......@@ -259,6 +273,55 @@ BOOL WINAPI NtUserSetSystemMenu( HWND hwnd, HMENU menu )
}
/*******************************************************************
* set_window_menu
*
* Helper for NtUserSetMenu that does not call NtUserSetWindowPos.
*/
BOOL set_window_menu( HWND hwnd, HMENU handle )
{
TRACE( "(%p, %p);\n", hwnd, handle );
if (handle && !is_menu( handle ))
{
WARN( "%p is not a menu handle\n", handle );
return FALSE;
}
if (is_win_menu_disallowed( hwnd ))
return FALSE;
hwnd = get_full_window_handle( hwnd );
if (get_capture() == hwnd)
set_capture_window( 0, GUI_INMENUMODE, NULL ); /* release the capture */
if (handle)
{
POPUPMENU *menu;
if (!(menu = grab_menu_ptr( handle ))) return FALSE;
menu->hWnd = hwnd;
menu->Height = 0; /* Make sure we recalculate the size */
release_menu_ptr(menu);
}
NtUserSetWindowLong( hwnd, GWLP_ID, (LONG_PTR)handle, FALSE );
return TRUE;
}
/**********************************************************************
* NtUserSetMenu (win32u.@)
*/
BOOL WINAPI NtUserSetMenu( HWND hwnd, HMENU menu )
{
if (!set_window_menu( hwnd, menu ))
return FALSE;
NtUserSetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
return TRUE;
}
/*******************************************************************
* NtUserCheckMenuItem (win32u.@)
*/
DWORD WINAPI NtUserCheckMenuItem( HMENU handle, UINT id, UINT flags )
......
......@@ -50,7 +50,6 @@ struct user_callbacks
BOOL (CDECL *process_rawinput_message)( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data );
BOOL (CDECL *rawinput_device_get_usages)(HANDLE handle, USHORT *usage_page, USHORT *usage);
void (CDECL *register_builtin_classes)(void);
BOOL (CDECL *set_menu)( HWND hwnd, HMENU menu );
void (WINAPI *set_standard_scroll_painted)( HWND hwnd, INT bar, BOOL visible );
BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size );
......
......@@ -1206,7 +1206,7 @@
@ stdcall NtUserSetLayeredWindowAttributes(ptr long long long)
@ stub NtUserSetMagnificationDesktopMagnifierOffsetsDWMUpdated
@ stub NtUserSetManipulationInputTarget
@ stub NtUserSetMenu
@ stdcall NtUserSetMenu(long long)
@ stdcall -syscall NtUserSetMenuContextHelpId(long long)
@ stub NtUserSetMenuDefaultItem
@ stub NtUserSetMenuFlagRtoL
......
......@@ -269,6 +269,7 @@ struct unix_funcs
BOOL (WINAPI *pNtUserSetCursorPos)( INT x, INT y );
HWND (WINAPI *pNtUserSetFocus)( HWND hwnd );
BOOL (WINAPI *pNtUserSetLayeredWindowAttributes)( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags );
BOOL (WINAPI *pNtUserSetMenu)( HWND hwnd, HMENU menu );
HWND (WINAPI *pNtUserSetParent)( HWND hwnd, HWND parent );
BOOL (WINAPI *pNtUserSetSysColors)( INT count, const INT *colors, const COLORREF *values );
LONG (WINAPI *pNtUserSetWindowLong)( HWND hwnd, INT offset, LONG newval, BOOL ansi );
......@@ -346,6 +347,7 @@ extern BOOL unhook_windows_hook( INT id, HOOKPROC proc ) DECLSPEC_HIDDEN;
/* input.c */
extern LONG global_key_state_counter DECLSPEC_HIDDEN;
extern HWND get_active_window(void) DECLSPEC_HIDDEN;
extern HWND get_capture(void) DECLSPEC_HIDDEN;
extern BOOL get_cursor_pos( POINT *pt ) DECLSPEC_HIDDEN;
extern HWND get_focus(void) DECLSPEC_HIDDEN;
extern DWORD get_input_state(void) DECLSPEC_HIDDEN;
......@@ -357,6 +359,7 @@ extern BOOL set_foreground_window( HWND hwnd, BOOL mouse ) DECLSPEC_HIDDEN;
extern HMENU create_menu( BOOL is_popup ) DECLSPEC_HIDDEN;
extern BOOL draw_menu_bar( HWND hwnd ) DECLSPEC_HIDDEN;
extern HMENU get_menu( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL set_window_menu( HWND hwnd, HMENU handle ) DECLSPEC_HIDDEN;
/* message.c */
extern LRESULT dispatch_message( const MSG *msg, BOOL ansi ) DECLSPEC_HIDDEN;
......
......@@ -4994,7 +4994,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
if ((win->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD)
{
if (cs.hMenu && user_callbacks && !user_callbacks->set_menu( hwnd, cs.hMenu ))
if (cs.hMenu && !set_window_menu( hwnd, cs.hMenu ))
{
release_win_ptr( win );
free_window_handle( hwnd );
......
......@@ -1113,6 +1113,12 @@ BOOL WINAPI NtUserSetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alph
return unix_funcs->pNtUserSetLayeredWindowAttributes( hwnd, key, alpha, flags );
}
BOOL WINAPI NtUserSetMenu( HWND hwnd, HMENU menu )
{
if (!unix_funcs) return FALSE;
return unix_funcs->pNtUserSetMenu( hwnd, menu );
}
HWND WINAPI NtUserSetParent( HWND hwnd, HWND parent )
{
if (!unix_funcs) return 0;
......
......@@ -554,6 +554,7 @@ BOOL WINAPI NtUserSetCursorPos( INT x, INT y );
HWND WINAPI NtUserSetFocus( HWND hwnd );
BOOL WINAPI NtUserSetKeyboardState( BYTE *state );
BOOL WINAPI NtUserSetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags );
BOOL WINAPI NtUserSetMenu( HWND hwnd, HMENU menu );
BOOL WINAPI NtUserSetMenuContextHelpId( HMENU handle, DWORD id );
HWND WINAPI NtUserSetParent( HWND hwnd, HWND parent );
BOOL WINAPI NtUserSetProcessDpiAwarenessContext( ULONG awareness, ULONG unknown );
......
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