/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id$
- *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Menus
*/
/* INCLUDES ******************************************************************/
-#include <w32k.h>
+#include <win32k.h>
#define NDEBUG
#include <debug.h>
PMENU_OBJECT FASTCALL
-IntGetSystemMenu(PWINDOW_OBJECT Window, BOOL bRevert, BOOL RetMenu);
+IntGetSystemMenu(PWND Window, BOOL bRevert, BOOL RetMenu);
( ((r).bottom >= y)) && \
( ((r).top <= y)) )
-NTSTATUS FASTCALL
+INIT_FUNCTION
+NTSTATUS
+NTAPI
InitMenuImpl(VOID)
{
return(STATUS_SUCCESS);
return NULL;
}
- ASSERT(USER_BODY_TO_HEADER(Menu)->RefCount >= 0);
+ ASSERT(Menu->head.cLockObj >= 0);
return Menu;
}
PMENU_OBJECT Menu = UserGetMenuObject(hMenu);
if (Menu)
{
- ASSERT(USER_BODY_TO_HEADER(Menu)->RefCount >= 0);
+ ASSERT(Menu->head.cLockObj >= 0);
- USER_BODY_TO_HEADER(Menu)->RefCount++;
+ Menu->head.cLockObj++;
}
return Menu;
}
{
if(Menu)
{
- PWINDOW_OBJECT Window;
+ PWND Window;
PWINSTATION_OBJECT WindowStation;
NTSTATUS Status;
NULL);
if(NT_SUCCESS(Status))
{
+ BOOL ret;
if (Menu->MenuInfo.Wnd)
{
Window = UserGetWindowObject(Menu->MenuInfo.Wnd);
if (Window)
{
- Window->Wnd->IDMenu = 0;
+ Window->IDMenu = 0;
}
}
// UserDereferenceObject(Menu);
- BOOL ret = UserDeleteObject(Menu->MenuInfo.Self, otMenu);
+ ret = UserDeleteObject(Menu->MenuInfo.Self, otMenu);
ObDereferenceObject(WindowStation);
return ret;
}
IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar)
{
PMENU_OBJECT Menu;
- PW32PROCESS CurrentWin32Process;
-
- Menu = (PMENU_OBJECT)UserCreateObject(
- gHandleTable, Handle,
- otMenu, sizeof(MENU_OBJECT));
+ PPROCESSINFO CurrentWin32Process;
+ Menu = (PMENU_OBJECT)UserCreateObject( gHandleTable,
+ NULL,
+ Handle,
+ otMenu,
+ sizeof(MENU_OBJECT));
if(!Menu)
{
*Handle = 0;
NewMenuItem->Text.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, MenuItem->Text.MaximumLength, TAG_STRING);
if(!NewMenuItem->Text.Buffer)
{
- ExFreePool(NewMenuItem);
+ ExFreePoolWithTag(NewMenuItem, TAG_MENUITEM);
break;
}
RtlCopyUnicodeString(&NewMenuItem->Text, &MenuItem->Text);
PMENU_OBJECT FASTCALL
IntCloneMenu(PMENU_OBJECT Source)
{
- PW32PROCESS CurrentWin32Process;
+ PPROCESSINFO CurrentWin32Process;
HANDLE hMenu;
PMENU_OBJECT Menu;
if(!Source)
return NULL;
- Menu = (PMENU_OBJECT)UserCreateObject(
- gHandleTable, &hMenu,
- otMenu, sizeof(MENU_OBJECT));
-
+ Menu = (PMENU_OBJECT)UserCreateObject( gHandleTable,
+ NULL,
+ &hMenu,
+ otMenu,
+ sizeof(MENU_OBJECT));
if(!Menu)
return NULL;
return TRUE;
}
-
-BOOL FASTCALL
-IntIsMenu(HMENU hMenu)
-{
- PMENU_OBJECT Menu;
-
- if((Menu = UserGetMenuObject(hMenu)))
- {
- return TRUE;
- }
- return FALSE;
-}
-
-
BOOL FASTCALL
IntSetMenuInfo(PMENU_OBJECT Menu, PROSMENUINFO lpmi)
{
if(CurItem->fType & MF_POPUP)
{
PMENU_OBJECT NewMenu = UserGetMenuObject(CurItem->hSubMenu);
- if(Menu)
+ if(NewMenu)
{
ret = IntGetMenuItemByFlag(NewMenu, uSearchBy, fFlag,
SubMenu, MenuItem, PrevMenuItem);
if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
{
lpmii->Rect = MenuItem->Rect;
- lpmii->XTab = MenuItem->XTab;
- lpmii->Text = MenuItem->Text.Buffer;
+ lpmii->dxTab = MenuItem->dxTab;
+ lpmii->lpstr = MenuItem->Text.Buffer; // Use DesktopHeap!
}
return TRUE;
if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
{
MenuItem->Rect = lpmii->Rect;
- MenuItem->XTab = lpmii->XTab;
- lpmii->Text = MenuItem->Text.Buffer; /* Send back new allocated string or zero */
+ MenuItem->dxTab = lpmii->dxTab;
+ lpmii->lpstr = MenuItem->Text.Buffer; /* Use DesktopHeap! Send back new allocated string or zero */
}
return TRUE;
if(!IntSetMenuItemInfo(SubMenu, MenuItem, ItemInfo))
{
- ExFreePool(MenuItem);
+ ExFreePoolWithTag(MenuItem, TAG_MENUITEM);
return FALSE;
}
IntBuildMenuItemList(PMENU_OBJECT MenuObject, PVOID Buffer, ULONG nMax)
{
DWORD res = 0;
- UINT sz;
ROSMENUITEMINFO mii;
PVOID Buf;
PMENU_ITEM CurItem = MenuObject->MenuItemList;
StrOut = (PWCHAR)((char *) Buffer + MenuObject->MenuInfo.MenuItemCount
* sizeof(ROSMENUITEMINFO));
nMax -= MenuObject->MenuInfo.MenuItemCount * sizeof(ROSMENUITEMINFO);
- sz = sizeof(ROSMENUITEMINFO);
Buf = Buffer;
mii.cbSize = sizeof(ROSMENUITEMINFO);
mii.fMask = 0;
}
mii.fState = CurItem->fState;
mii.fType = CurItem->fType;
+ mii.wID = CurItem->wID;
mii.hbmpChecked = CurItem->hbmpChecked;
mii.hbmpItem = CurItem->hbmpItem;
mii.hbmpUnchecked = CurItem->hbmpUnchecked;
mii.hSubMenu = CurItem->hSubMenu;
mii.Rect = CurItem->Rect;
- mii.XTab = CurItem->XTab;
- mii.Text = CurItem->Text.Buffer;
+ mii.dxTab = CurItem->dxTab;
+ mii.lpstr = CurItem->Text.Buffer; // Use DesktopHeap!
Status = MmCopyToCaller(Buf, &mii, sizeof(ROSMENUITEMINFO));
if (! NT_SUCCESS(Status))
}
BOOL FASTCALL
-IntHiliteMenuItem(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject,
+IntHiliteMenuItem(PWND WindowObject, PMENU_OBJECT MenuObject,
UINT uItemHilite, UINT uHilite)
{
PMENU_ITEM MenuItem;
}
VOID FASTCALL
-co_IntInitTracking(PWINDOW_OBJECT Window, PMENU_OBJECT Menu, BOOL Popup,
+co_IntInitTracking(PWND Window, PMENU_OBJECT Menu, BOOL Popup,
UINT Flags)
{
/* FIXME - hide caret */
if(!(Flags & TPM_NONOTIFY))
- co_IntSendMessage(Window->hSelf, WM_SETCURSOR, (WPARAM)Window->hSelf, HTCAPTION);
+ co_IntSendMessage(Window->head.h, WM_SETCURSOR, (WPARAM)Window->head.h, HTCAPTION);
/* FIXME - send WM_SETCURSOR message */
if(!(Flags & TPM_NONOTIFY))
- co_IntSendMessage(Window->hSelf, WM_INITMENU, (WPARAM)Menu->MenuInfo.Self, 0);
+ co_IntSendMessage(Window->head.h, WM_INITMENU, (WPARAM)Menu->MenuInfo.Self, 0);
}
VOID FASTCALL
-co_IntExitTracking(PWINDOW_OBJECT Window, PMENU_OBJECT Menu, BOOL Popup,
+co_IntExitTracking(PWND Window, PMENU_OBJECT Menu, BOOL Popup,
UINT Flags)
{
if(!(Flags & TPM_NONOTIFY))
- co_IntSendMessage(Window->hSelf, WM_EXITMENULOOP, 0 /* FIXME */, 0);
+ co_IntSendMessage(Window->head.h, WM_EXITMENULOOP, 0 /* FIXME */, 0);
/* FIXME - Show caret again */
}
INT FASTCALL
-IntTrackMenu(PMENU_OBJECT Menu, PWINDOW_OBJECT Window, INT x, INT y,
- RECT lprect)
+IntTrackMenu(PMENU_OBJECT Menu, PWND Window, INT x, INT y,
+ RECTL lprect)
{
return 0;
}
BOOL FASTCALL
-co_IntTrackPopupMenu(PMENU_OBJECT Menu, PWINDOW_OBJECT Window,
- UINT Flags, POINT *Pos, UINT MenuPos, RECT *ExcludeRect)
+co_IntTrackPopupMenu(PMENU_OBJECT Menu, PWND Window,
+ UINT Flags, POINT *Pos, UINT MenuPos, RECTL *ExcludeRect)
{
co_IntInitTracking(Window, Menu, TRUE, Flags);
}
BOOL FASTCALL
-IntSetMenuItemRect(PMENU_OBJECT Menu, UINT Item, BOOL fByPos, RECT *rcRect)
+IntSetMenuItemRect(PMENU_OBJECT Menu, UINT Item, BOOL fByPos, RECTL *rcRect)
{
PMENU_ITEM mi;
if(IntGetMenuItemByFlag(Menu, Item, (fByPos ? MF_BYPOSITION : MF_BYCOMMAND),
* Internal function. Called when the process is destroyed to free the remaining menu handles.
*/
BOOL FASTCALL
-IntCleanupMenus(struct _EPROCESS *Process, PW32PROCESS Win32Process)
+IntCleanupMenus(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
{
PEPROCESS CurrentProcess;
PLIST_ENTRY LastHead = NULL;
return TRUE;
}
-VOID STDCALL
-co_InflateRect(LPRECT rect, int dx, int dy)
-{
- rect->left -= dx;
- rect->top -= dy;
- rect->right += dx;
- rect->bottom += dy;
-}
-
-BOOLEAN STDCALL
-intGetTitleBarInfo(PWINDOW_OBJECT pWindowObject, PTITLEBARINFO bti)
+BOOLEAN APIENTRY
+intGetTitleBarInfo(PWND pWindowObject, PTITLEBARINFO bti)
{
DWORD dwStyle = 0;
bti->rgstate[0] = STATE_SYSTEM_FOCUSABLE;
- dwStyle = pWindowObject->Wnd->Style;
- dwExStyle = pWindowObject->Wnd->ExStyle;
+ dwStyle = pWindowObject->style;
+ dwExStyle = pWindowObject->ExStyle;
bti->rcTitleBar.top = 0;
bti->rcTitleBar.left = 0;
- bti->rcTitleBar.right = pWindowObject->Wnd->WindowRect.right - pWindowObject->Wnd->WindowRect.left;
- bti->rcTitleBar.bottom = pWindowObject->Wnd->WindowRect.bottom - pWindowObject->Wnd->WindowRect.top;
+ bti->rcTitleBar.right = pWindowObject->rcWindow.right - pWindowObject->rcWindow.left;
+ bti->rcTitleBar.bottom = pWindowObject->rcWindow.bottom - pWindowObject->rcWindow.top;
/* is it iconiced ? */
if ((dwStyle & WS_ICONIC)!=WS_ICONIC)
if (HAS_THICKFRAME( dwStyle, dwExStyle ))
{
/* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXFRAME) and UserGetSystemMetrics(SM_CYFRAME) */
- co_InflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXFRAME), -UserGetSystemMetrics(SM_CYFRAME) );
+ RECTL_vInflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXFRAME), -UserGetSystemMetrics(SM_CYFRAME) );
}
else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
{
/* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXDLGFRAME) and UserGetSystemMetrics(SM_CYDLGFRAME) */
- co_InflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXDLGFRAME), -UserGetSystemMetrics(SM_CYDLGFRAME));
+ RECTL_vInflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXDLGFRAME), -UserGetSystemMetrics(SM_CYDLGFRAME));
}
else if (HAS_THINFRAME( dwStyle, dwExStyle))
{
/* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
- co_InflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER) );
+ RECTL_vInflateRect( &bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER) );
}
/* We have additional border information if the window
if (dwExStyle & WS_EX_CLIENTEDGE)
{
/* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXEDGE) and UserGetSystemMetrics(SM_CYEDGE) */
- co_InflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXEDGE), -UserGetSystemMetrics(SM_CYEDGE));
+ RECTL_vInflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXEDGE), -UserGetSystemMetrics(SM_CYEDGE));
}
if (dwExStyle & WS_EX_STATICEDGE)
{
/* FIXME : Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
- co_InflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER));
+ RECTL_vInflateRect (&bti->rcTitleBar, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER));
}
}
}
- bti->rcTitleBar.top += pWindowObject->Wnd->WindowRect.top;
- bti->rcTitleBar.left += pWindowObject->Wnd->WindowRect.left;
- bti->rcTitleBar.right += pWindowObject->Wnd->WindowRect.left;
+ bti->rcTitleBar.top += pWindowObject->rcWindow.top;
+ bti->rcTitleBar.left += pWindowObject->rcWindow.left;
+ bti->rcTitleBar.right += pWindowObject->rcWindow.left;
bti->rcTitleBar.bottom = bti->rcTitleBar.top;
if (dwExStyle & WS_EX_TOOLWINDOW)
{
bti->rgstate[4] = STATE_SYSTEM_INVISIBLE;
}
- if (pWindowObject->Wnd->Class->Style & CS_NOCLOSE)
+ if (pWindowObject->pcls->style & CS_NOCLOSE)
{
bti->rgstate[5] = STATE_SYSTEM_UNAVAILABLE;
}
return retValue;
}
-/* FUNCTIONS *****************************************************************/
-
-
-/*
- * @implemented
- */
-DWORD
-STDCALL
-NtUserBuildMenuItemList(
- HMENU hMenu,
- VOID* Buffer,
- ULONG nBufSize,
- DWORD Reserved)
+DWORD FASTCALL
+UserInsertMenuItem(
+ PMENU_OBJECT Menu,
+ UINT uItem,
+ BOOL fByPosition,
+ LPCMENUITEMINFOW UnsafeItemInfo)
{
- DWORD res = -1;
- PMENU_OBJECT Menu;
- DECLARE_RETURN(DWORD);
-
- DPRINT("Enter NtUserBuildMenuItemList\n");
- UserEnterExclusive();
+ NTSTATUS Status;
+ ROSMENUITEMINFO ItemInfo;
- if(!(Menu = UserGetMenuObject(hMenu)))
+ /* Try to copy the whole MENUITEMINFOW structure */
+ Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
+ if (NT_SUCCESS(Status))
{
- RETURN( (DWORD)-1);
+ if (sizeof(MENUITEMINFOW) != ItemInfo.cbSize
+ && FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ return IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo);
}
- if(Buffer)
- {
- res = IntBuildMenuItemList(Menu, Buffer, nBufSize);
- }
- else
+ /* Try to copy without last field (not present in older versions) */
+ Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, FIELD_OFFSET(MENUITEMINFOW, hbmpItem));
+ if (NT_SUCCESS(Status))
{
- res = Menu->MenuInfo.MenuItemCount;
+ if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ ItemInfo.hbmpItem = (HBITMAP)0;
+ return IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo);
}
- RETURN( res);
-
-CLEANUP:
- DPRINT("Leave NtUserBuildMenuItemList, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
+ SetLastNtError(Status);
+ return FALSE;
}
+/* FUNCTIONS *****************************************************************/
+
/*
* @implemented
*/
-DWORD STDCALL
+DWORD APIENTRY
NtUserCheckMenuItem(
HMENU hMenu,
UINT uIDCheckItem,
END_CLEANUP;
}
-
HMENU FASTCALL UserCreateMenu(BOOL PopupMenu)
{
PWINSTATION_OBJECT WinStaObject;
return (HMENU)0;
}
Menu = IntCreateMenu(&Handle, !PopupMenu);
- UserDereferenceObject(Menu);
ObDereferenceObject(WinStaObject);
}
else
{
Menu = IntCreateMenu(&Handle, !PopupMenu);
- UserDereferenceObject(Menu);
}
+ if (Menu) UserDereferenceObject(Menu);
return (HMENU)Handle;
}
-
/*
* @implemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserDeleteMenu(
HMENU hMenu,
UINT uPosition,
/*
* @implemented
*/
-BOOLEAN STDCALL
+BOOLEAN APIENTRY
NtUserGetTitleBarInfo(
HWND hwnd,
PTITLEBARINFO bti)
{
- PWINDOW_OBJECT WindowObject;
+ PWND WindowObject;
TITLEBARINFO bartitleinfo;
DECLARE_RETURN(BOOLEAN);
BOOLEAN retValue = TRUE;
retValue = FALSE;
}
- _SEH_TRY
+ _SEH2_TRY
{
/* Copy our usermode buffer bti to local buffer bartitleinfo */
ProbeForRead(bti, sizeof(TITLEBARINFO), 1);
RtlCopyMemory(&bartitleinfo, bti, sizeof(TITLEBARINFO));
}
- _SEH_HANDLE
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Fail copy the data */
SetLastWin32Error(ERROR_INVALID_PARAMETER);
retValue = FALSE;
}
- _SEH_END
+ _SEH2_END
/* Get the tile bar info */
if (retValue)
retValue = intGetTitleBarInfo(WindowObject, &bartitleinfo);
if (retValue)
{
- _SEH_TRY
+ _SEH2_TRY
{
/* Copy our buffer to user mode buffer bti */
ProbeForWrite(bti, sizeof(TITLEBARINFO), 1);
RtlCopyMemory(bti, &bartitleinfo, sizeof(TITLEBARINFO));
}
- _SEH_HANDLE
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Fail copy the data */
SetLastWin32Error(ERROR_INVALID_PARAMETER);
retValue = FALSE;
}
- _SEH_END
+ _SEH2_END
}
}
END_CLEANUP;
}
-
-
/*
* @implemented
*/
/*
* @implemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserDestroyMenu(
HMENU hMenu)
{
END_CLEANUP;
}
-
/*
* @implemented
*/
-UINT STDCALL
+UINT APIENTRY
NtUserEnableMenuItem(
HMENU hMenu,
UINT uIDEnableItem,
END_CLEANUP;
}
-
-/*
- * @implemented
- */
-DWORD STDCALL
-UserInsertMenuItem(
- HMENU hMenu,
- UINT uItem,
- BOOL fByPosition,
- LPCMENUITEMINFOW UnsafeItemInfo)
-{
- PMENU_OBJECT Menu;
- NTSTATUS Status;
- ROSMENUITEMINFO ItemInfo;
- DECLARE_RETURN(DWORD);
-
- DPRINT("Enter UserInsertMenuItem\n");
- UserEnterExclusive();
-
- if(!(Menu = UserGetMenuObject(hMenu)))
- {
- RETURN( FALSE);
- }
-
- /* Try to copy the whole MENUITEMINFOW structure */
- Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
- if (NT_SUCCESS(Status))
- {
- if (sizeof(MENUITEMINFOW) != ItemInfo.cbSize
- && FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
- {
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
- RETURN( FALSE);
- }
- RETURN( IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo));
- }
-
- /* Try to copy without last field (not present in older versions) */
- Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, FIELD_OFFSET(MENUITEMINFOW, hbmpItem));
- if (NT_SUCCESS(Status))
- {
- if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
- {
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
- RETURN( FALSE);
- }
- ItemInfo.hbmpItem = (HBITMAP)0;
- RETURN( IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo));
- }
-
- SetLastNtError(Status);
- RETURN( FALSE);
-
-CLEANUP:
- DPRINT("Leave UserInsertMenuItem, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-
/*
* @unimplemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserEndMenu(VOID)
{
UNIMPLEMENTED
return 0;
}
-
/*
* @implemented
*/
-UINT STDCALL
-NtUserGetMenuDefaultItem(
- HMENU hMenu,
- UINT fByPos,
- UINT gmdiFlags)
-{
- PMENU_OBJECT Menu;
- DWORD gismc = 0;
- DECLARE_RETURN(UINT);
-
- DPRINT("Enter NtUserGetMenuDefaultItem\n");
- UserEnterExclusive();
-
- if(!(Menu = UserGetMenuObject(hMenu)))
- {
- RETURN(-1);
- }
-
- RETURN( IntGetMenuDefaultItem(Menu, fByPos, gmdiFlags, &gismc));
-
-CLEANUP:
- DPRINT("Leave NtUserGetMenuDefaultItem, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-
-/*
- * @implemented
- */
-BOOL STDCALL
+BOOL APIENTRY
NtUserGetMenuBarInfo(
HWND hwnd,
LONG idObject,
BOOL Res = TRUE;
PMENU_OBJECT MenuObject;
PMENU_ITEM mi;
- PWINDOW_OBJECT WindowObject;
+ PWND WindowObject;
HMENU hMenu;
POINT Offset;
- RECT Rect;
+ RECTL Rect;
MENUBARINFO kmbi;
DECLARE_RETURN(BOOL);
RETURN(FALSE);
}
- hMenu = (HMENU)WindowObject->Wnd->IDMenu;
+ hMenu = (HMENU)(DWORD_PTR)WindowObject->IDMenu;
if (!(MenuObject = UserGetMenuObject(hMenu)))
{
}
else
{
- PWINDOW_OBJECT SubWinObj;
+ PWND SubWinObj;
if (!(SubWinObj = UserGetWindowObject(SubMenuObject->MenuInfo.Wnd)))
{
Res = FALSE;
}
else
{
- PWINDOW_OBJECT SysWinObj;
+ PWND SysWinObj;
if (!(SysWinObj = UserGetWindowObject(SysMenuObject->MenuInfo.Wnd)))
{
Res = FALSE;
END_CLEANUP;
}
-
/*
- * @unimplemented
+ * @implemented
*/
-UINT STDCALL
+UINT APIENTRY
NtUserGetMenuIndex(
HMENU hMenu,
- UINT wID)
+ HMENU hSubMenu)
{
- UNIMPLEMENTED
+ PMENU_OBJECT Menu, SubMenu;
+ PMENU_ITEM MenuItem;
+ DECLARE_RETURN(UINT);
- return 0;
-}
+ DPRINT("Enter NtUserGetMenuIndex\n");
+ UserEnterShared();
+ if ( !(Menu = UserGetMenuObject(hMenu)) ||
+ !(SubMenu = UserGetMenuObject(hSubMenu)) )
+ RETURN(0xFFFFFFFF);
+
+ MenuItem = Menu->MenuItemList;
+ while(MenuItem)
+ {
+ if (MenuItem->hSubMenu == hSubMenu)
+ RETURN(MenuItem->wID);
+ MenuItem = MenuItem->Next;
+ }
+
+ RETURN(0xFFFFFFFF);
+
+CLEANUP:
+ DPRINT("Leave NtUserGetMenuIndex, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
/*
* @implemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserGetMenuItemRect(
HWND hWnd,
HMENU hMenu,
UINT uItem,
- LPRECT lprcItem)
+ PRECTL lprcItem)
{
ROSMENUINFO mi;
- PWINDOW_OBJECT ReferenceWnd;
+ PWND ReferenceWnd;
LONG XMove, YMove;
- RECT Rect;
+ RECTL Rect;
NTSTATUS Status;
PMENU_OBJECT Menu;
PMENU_ITEM MenuItem;
if(MenuItem->fType & MF_POPUP)
{
- XMove = ReferenceWnd->Wnd->ClientRect.left;
- YMove = ReferenceWnd->Wnd->ClientRect.top;
+ XMove = ReferenceWnd->rcClient.left;
+ YMove = ReferenceWnd->rcClient.top;
}
else
{
- XMove = ReferenceWnd->Wnd->WindowRect.left;
- YMove = ReferenceWnd->Wnd->WindowRect.top;
+ XMove = ReferenceWnd->rcWindow.left;
+ YMove = ReferenceWnd->rcWindow.top;
}
Rect.left += XMove;
END_CLEANUP;
}
-
/*
* @implemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserHiliteMenuItem(
HWND hWnd,
HMENU hMenu,
UINT uHilite)
{
PMENU_OBJECT Menu;
- PWINDOW_OBJECT Window;
+ PWND Window;
DECLARE_RETURN(BOOLEAN);
DPRINT("Enter NtUserHiliteMenuItem\n");
RETURN(FALSE);
}
- if(Window->Wnd->IDMenu == (UINT)hMenu)
+ if(Window->IDMenu == (UINT)(UINT_PTR)hMenu)
{
RETURN( IntHiliteMenuItem(Window, Menu, uItemHilite, uHilite));
}
END_CLEANUP;
}
-
static
BOOL FASTCALL
UserMenuInfo(
return( Res);
}
-
-
-
-
/*
* @implemented
*/
-BOOL
-STDCALL
-NtUserMenuInfo(
- HMENU hMenu,
- PROSMENUINFO UnsafeMenuInfo,
- BOOL SetOrGet)
-{
- PMENU_OBJECT Menu;
- DECLARE_RETURN(BOOL);
-
- DPRINT("Enter NtUserMenuInfo\n");
- UserEnterShared();
-
- if (!(Menu = UserGetMenuObject(hMenu)))
- {
- RETURN(FALSE);
- }
-
- RETURN(UserMenuInfo(Menu, UnsafeMenuInfo, SetOrGet));
-
-CLEANUP:
- DPRINT("Leave NtUserMenuInfo, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-
-
-/*
- * @implemented
- */
-int STDCALL
+int APIENTRY
NtUserMenuItemFromPoint(
HWND hWnd,
HMENU hMenu,
DWORD Y)
{
PMENU_OBJECT Menu;
- PWINDOW_OBJECT Window = NULL;
+ PWND Window = NULL;
PMENU_ITEM mi;
int i;
DECLARE_RETURN(int);
RETURN( -1);
}
- X -= Window->Wnd->WindowRect.left;
- Y -= Window->Wnd->WindowRect.top;
+ X -= Window->rcWindow.left;
+ Y -= Window->rcWindow.top;
mi = Menu->MenuItemList;
for (i = 0; NULL != mi; i++)
END_CLEANUP;
}
-
-
static
BOOL FASTCALL
UserMenuItemInfo(
return( Ret);
}
-
-
/*
* @implemented
*/
-BOOL
-STDCALL
-NtUserMenuItemInfo(
- HMENU hMenu,
- UINT Item,
- BOOL ByPosition,
- PROSMENUITEMINFO UnsafeItemInfo,
- BOOL SetOrGet)
-{
- PMENU_OBJECT Menu;
- DECLARE_RETURN(BOOL);
-
- DPRINT("Enter NtUserMenuItemInfo\n");
- UserEnterExclusive();
-
- if (!(Menu = UserGetMenuObject(hMenu)))
- {
- RETURN(FALSE);
- }
-
- RETURN( UserMenuItemInfo(Menu, Item, ByPosition, UnsafeItemInfo, SetOrGet));
-
-CLEANUP:
- DPRINT("Leave NtUserMenuItemInfo, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-
-}
-
-
-/*
- * @implemented
- */
-BOOL STDCALL
+BOOL APIENTRY
NtUserRemoveMenu(
HMENU hMenu,
UINT uPosition,
}
-
/*
* @implemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserSetMenuContextHelpId(
HMENU hMenu,
DWORD dwContextHelpId)
END_CLEANUP;
}
-
-
/*
* @implemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserSetMenuDefaultItem(
HMENU hMenu,
UINT uItem,
END_CLEANUP;
}
-
/*
* @implemented
*/
-BOOL STDCALL
+BOOL APIENTRY
NtUserSetMenuFlagRtoL(
HMENU hMenu)
{
END_CLEANUP;
}
-
/*
- * @unimplemented
+ * @implemented
*/
-DWORD STDCALL
+BOOL APIENTRY
NtUserThunkedMenuInfo(
HMENU hMenu,
LPCMENUINFO lpcmi)
{
- UNIMPLEMENTED
- /* This function seems just to call SetMenuInfo() */
- return 0;
-}
+ PMENU_OBJECT Menu;
+ DECLARE_RETURN(BOOL);
+ DPRINT("Enter NtUserThunkedMenuInfo\n");
+ UserEnterExclusive();
+
+ if (!(Menu = UserGetMenuObject(hMenu)))
+ {
+ RETURN(FALSE);
+ }
+
+ RETURN(UserMenuInfo(Menu, (PROSMENUINFO)lpcmi, TRUE));
+
+CLEANUP:
+ DPRINT("Leave NtUserThunkedMenuInfo, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
/*
- * @unimplemented
+ * @implemented
*/
-DWORD STDCALL
+BOOL APIENTRY
NtUserThunkedMenuItemInfo(
HMENU hMenu,
UINT uItem,
LPMENUITEMINFOW lpmii,
PUNICODE_STRING lpszCaption)
{
+ PMENU_OBJECT Menu;
+ NTSTATUS Status;
+ UNICODE_STRING lstrCaption;
+ DECLARE_RETURN(BOOL);
+
+ DPRINT("Enter NtUserThunkedMenuItemInfo\n");
+ UserEnterExclusive();
/* lpszCaption may be NULL, check for it and call RtlInitUnicodeString()
- if bInsert == TRUE call NtUserInsertMenuItem() else NtUserSetMenuItemInfo() */
+ if bInsert == TRUE call UserInsertMenuItem() else UserSetMenuItemInfo() */
- if (bInsert) return UserInsertMenuItem(hMenu, uItem, fByPosition, lpmii);
-
- UNIMPLEMENTED
- return 0;
-}
+ if (!(Menu = UserGetMenuObject(hMenu)))
+ {
+ RETURN(FALSE);
+ }
+
+ lstrCaption.Buffer = NULL;
+ /* Check if we got a Caption */
+ if (lpszCaption)
+ {
+ /* Copy the string to kernel mode */
+ Status = ProbeAndCaptureUnicodeString( &lstrCaption,
+ UserMode,
+ lpszCaption);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to capture MenuItem Caption (status 0x%08x)\n",Status);
+ SetLastNtError(Status);
+ RETURN(FALSE);
+ }
+ }
+
+ if (bInsert) RETURN( UserInsertMenuItem(Menu, uItem, fByPosition, lpmii));
+
+ RETURN( UserMenuItemInfo(Menu, uItem, fByPosition, (PROSMENUITEMINFO)lpmii, TRUE));
+
+CLEANUP:
+ DPRINT("Leave NtUserThunkedMenuItemInfo, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
/*
* @implemented
*/
/* NOTE: unused function */
-BOOL STDCALL
+BOOL APIENTRY
NtUserTrackPopupMenuEx(
HMENU hMenu,
UINT fuFlags,
}
+////// ReactOS NtUserBad
+/*
+ * @implemented
+ */
+DWORD
+APIENTRY
+NtUserBuildMenuItemList(
+ HMENU hMenu,
+ VOID* Buffer,
+ ULONG nBufSize,
+ DWORD Reserved)
+{
+ DWORD res = -1;
+ PMENU_OBJECT Menu;
+ DECLARE_RETURN(DWORD);
+
+ DPRINT("Enter NtUserBuildMenuItemList\n");
+ UserEnterExclusive();
+
+ if(!(Menu = UserGetMenuObject(hMenu)))
+ {
+ RETURN( (DWORD)-1);
+ }
+
+ if(Buffer)
+ {
+ res = IntBuildMenuItemList(Menu, Buffer, nBufSize);
+ }
+ else
+ {
+ res = Menu->MenuInfo.MenuItemCount;
+ }
+
+ RETURN( res);
+
+CLEANUP:
+ DPRINT("Leave NtUserBuildMenuItemList, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
+
+/*
+ * @implemented
+ */
+UINT APIENTRY
+NtUserGetMenuDefaultItem(
+ HMENU hMenu,
+ UINT fByPos,
+ UINT gmdiFlags)
+{
+ PMENU_OBJECT Menu;
+ DWORD gismc = 0;
+ DECLARE_RETURN(UINT);
+
+ DPRINT("Enter NtUserGetMenuDefaultItem\n");
+ UserEnterExclusive();
+
+ if(!(Menu = UserGetMenuObject(hMenu)))
+ {
+ RETURN(-1);
+ }
+
+ RETURN( IntGetMenuDefaultItem(Menu, fByPos, gmdiFlags, &gismc));
+
+CLEANUP:
+ DPRINT("Leave NtUserGetMenuDefaultItem, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+APIENTRY
+NtUserMenuInfo(
+ HMENU hMenu,
+ PROSMENUINFO UnsafeMenuInfo,
+ BOOL SetOrGet)
+{
+ PMENU_OBJECT Menu;
+ DECLARE_RETURN(BOOL);
+
+ DPRINT("Enter NtUserMenuInfo\n");
+ UserEnterShared();
+
+ if (!(Menu = UserGetMenuObject(hMenu)))
+ {
+ RETURN(FALSE);
+ }
+
+ RETURN(UserMenuInfo(Menu, UnsafeMenuInfo, SetOrGet));
+
+CLEANUP:
+ DPRINT("Leave NtUserMenuInfo, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+APIENTRY
+NtUserMenuItemInfo(
+ HMENU hMenu,
+ UINT Item,
+ BOOL ByPosition,
+ PROSMENUITEMINFO UnsafeItemInfo,
+ BOOL SetOrGet)
+{
+ PMENU_OBJECT Menu;
+ DECLARE_RETURN(BOOL);
+
+ DPRINT("Enter NtUserMenuItemInfo\n");
+ UserEnterExclusive();
+
+ if (!(Menu = UserGetMenuObject(hMenu)))
+ {
+ RETURN(FALSE);
+ }
+
+ RETURN( UserMenuItemInfo(Menu, Item, ByPosition, UnsafeItemInfo, SetOrGet));
+
+CLEANUP:
+ DPRINT("Leave NtUserMenuItemInfo, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+
+}
+
/* EOF */