mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Implement menu handling
svn path=/trunk/; revision=8195
This commit is contained in:
parent
a3ac53db3d
commit
6fc29ccca7
8 changed files with 2977 additions and 511 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <win32k/icm.h>
|
||||
#include <win32k/line.h>
|
||||
#include <win32k/metafile.h>
|
||||
#include <win32k/menu.h>
|
||||
#include <win32k/misc.h>
|
||||
#include <win32k/ntuser.h>
|
||||
#include <win32k/paint.h>
|
||||
|
|
249
reactos/include/win32k/menu.h
Normal file
249
reactos/include/win32k/menu.h
Normal file
|
@ -0,0 +1,249 @@
|
|||
/* $Id: menu.h,v 1.1 2004/02/15 07:39:12 gvg Exp $ */
|
||||
|
||||
#ifndef WIN32K_MENU_H_INCLUDED
|
||||
#define WIN32K_MENU_H_INCLUDED
|
||||
|
||||
typedef struct tagROSMENUINFO {
|
||||
/* ----------- MENUINFO ----------- */
|
||||
DWORD cbSize;
|
||||
DWORD fMask;
|
||||
DWORD dwStyle;
|
||||
UINT cyMax;
|
||||
HBRUSH hbrBack;
|
||||
DWORD dwContextHelpID;
|
||||
ULONG_PTR dwMenuData;
|
||||
/* ----------- Extra ----------- */
|
||||
HMENU Self; /* Handle of this menu */
|
||||
WORD Flags; /* Menu flags (MF_POPUP, MF_SYSMENU) */
|
||||
UINT FocusedItem; /* Currently focused item */
|
||||
UINT MenuItemCount; /* Number of items in the menu */
|
||||
HWND Wnd; /* Window containing the menu */
|
||||
WORD Width; /* Width of the whole menu */
|
||||
WORD Height; /* Height of the whole menu */
|
||||
HWND WndOwner; /* window receiving the messages for ownerdraw */
|
||||
BOOL TimeToHide; /* Request hiding when receiving a second click in the top-level menu item */
|
||||
} ROSMENUINFO, *PROSMENUINFO;
|
||||
|
||||
/* (other FocusedItem values give the position of the focused item) */
|
||||
#define NO_SELECTED_ITEM 0xffff
|
||||
|
||||
typedef struct tagROSMENUITEMINFO
|
||||
{
|
||||
/* ----------- MENUITEMINFOW ----------- */
|
||||
UINT cbSize;
|
||||
UINT fMask;
|
||||
UINT fType;
|
||||
UINT fState;
|
||||
UINT wID;
|
||||
HMENU hSubMenu;
|
||||
HBITMAP hbmpChecked;
|
||||
HBITMAP hbmpUnchecked;
|
||||
DWORD dwItemData;
|
||||
LPWSTR dwTypeData;
|
||||
UINT cch;
|
||||
HBITMAP hbmpItem;
|
||||
/* ----------- Extra ----------- */
|
||||
RECT Rect; /* Item area (relative to menu window) */
|
||||
UINT XTab; /* X position of text after Tab */
|
||||
} ROSMENUITEMINFO, *PROSMENUITEMINFO;
|
||||
|
||||
typedef struct _SETMENUITEMRECT
|
||||
{
|
||||
UINT uItem;
|
||||
BOOL fByPosition;
|
||||
RECT rcRect;
|
||||
} SETMENUITEMRECT, *PSETMENUITEMRECT;
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserBuildMenuItemList(
|
||||
HMENU hMenu,
|
||||
PVOID Buffer,
|
||||
ULONG nBufSize,
|
||||
DWORD Reserved);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserCheckMenuItem(
|
||||
HMENU hmenu,
|
||||
UINT uIDCheckItem,
|
||||
UINT uCheck);
|
||||
|
||||
HMENU
|
||||
STDCALL
|
||||
NtUserCreateMenu(BOOL PopupMenu);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserDeleteMenu(
|
||||
HMENU hMenu,
|
||||
UINT uPosition,
|
||||
UINT uFlags);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserDestroyMenu(
|
||||
HMENU hMenu);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserDrawMenuBarTemp(
|
||||
HWND hWnd,
|
||||
HDC hDC,
|
||||
PRECT hRect,
|
||||
HMENU hMenu,
|
||||
HFONT hFont);
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtUserEnableMenuItem(
|
||||
HMENU hMenu,
|
||||
UINT uIDEnableItem,
|
||||
UINT uEnable);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserInsertMenuItem(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
LPCMENUITEMINFOW lpmii);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserEndMenu(VOID);
|
||||
|
||||
UINT STDCALL
|
||||
NtUserGetMenuDefaultItem(
|
||||
HMENU hMenu,
|
||||
UINT fByPos,
|
||||
UINT gmdiFlags);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetMenuBarInfo(
|
||||
HWND hwnd,
|
||||
LONG idObject,
|
||||
LONG idItem,
|
||||
PMENUBARINFO pmbi);
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtUserGetMenuIndex(
|
||||
HMENU hMenu,
|
||||
UINT wID);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetMenuItemRect(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
LPRECT lprcItem);
|
||||
|
||||
HMENU
|
||||
STDCALL
|
||||
NtUserGetSystemMenu(
|
||||
HWND hWnd,
|
||||
BOOL bRevert);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserHiliteMenuItem(
|
||||
HWND hwnd,
|
||||
HMENU hmenu,
|
||||
UINT uItemHilite,
|
||||
UINT uHilite);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserMenuInfo(
|
||||
HMENU hmenu,
|
||||
PROSMENUINFO lpmi,
|
||||
BOOL fsog
|
||||
);
|
||||
|
||||
int
|
||||
STDCALL
|
||||
NtUserMenuItemFromPoint(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
DWORD X,
|
||||
DWORD Y);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserMenuItemInfo(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
PROSMENUITEMINFO lpmii,
|
||||
BOOL fsog
|
||||
);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserRemoveMenu(
|
||||
HMENU hMenu,
|
||||
UINT uPosition,
|
||||
UINT uFlags);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenu(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
BOOL bRepaint);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenuContextHelpId(
|
||||
HMENU hmenu,
|
||||
DWORD dwContextHelpId);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenuDefaultItem(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
UINT fByPos);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenuFlagRtoL(
|
||||
HMENU hMenu);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetSystemMenu(
|
||||
HWND hWnd,
|
||||
HMENU hMenu);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserThunkedMenuInfo(
|
||||
HMENU hMenu,
|
||||
LPCMENUINFO lpcmi);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserThunkedMenuItemInfo(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
BOOL bInsert,
|
||||
LPMENUITEMINFOW lpmii,
|
||||
PUNICODE_STRING lpszCaption);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserTrackPopupMenuEx(
|
||||
HMENU hmenu,
|
||||
UINT fuFlags,
|
||||
int x,
|
||||
int y,
|
||||
HWND hwnd,
|
||||
LPTPMPARAMS lptpm);
|
||||
|
||||
#endif /* WIN32K_MENU_H_INCLUDED */
|
||||
|
|
@ -84,14 +84,6 @@ NtUserBuildHwndList(
|
|||
HWND* pWnd,
|
||||
ULONG nBufSize);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserBuildMenuItemList(
|
||||
HMENU hMenu,
|
||||
PVOID Buffer,
|
||||
ULONG nBufSize,
|
||||
DWORD Reserved);
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtUserBuildNameList(
|
||||
HWINSTA hWinSta,
|
||||
|
@ -225,13 +217,6 @@ NtUserChangeDisplaySettings(
|
|||
DWORD dwflags,
|
||||
LPVOID lParam);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserCheckMenuItem(
|
||||
HMENU hmenu,
|
||||
UINT uIDCheckItem,
|
||||
UINT uCheck);
|
||||
|
||||
HWND STDCALL
|
||||
NtUserChildWindowFromPointEx(HWND Parent,
|
||||
LONG x,
|
||||
|
@ -311,10 +296,6 @@ NtUserCreateLocalMemHandle(
|
|||
DWORD Unknown2,
|
||||
DWORD Unknown3);
|
||||
|
||||
HMENU
|
||||
STDCALL
|
||||
NtUserCreateMenu(BOOL PopupMenu);
|
||||
|
||||
HWND
|
||||
STDCALL
|
||||
NtUserCreateWindowEx(
|
||||
|
@ -378,13 +359,6 @@ NtUserDeferWindowPos(HDWP WinPosInfo,
|
|||
BOOL STDCALL
|
||||
NtUserDefSetText(HWND WindowHandle, PANSI_STRING Text);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserDeleteMenu(
|
||||
HMENU hMenu,
|
||||
UINT uPosition,
|
||||
UINT uFlags);
|
||||
|
||||
BOOLEAN
|
||||
STDCALL
|
||||
NtUserDestroyAcceleratorTable(
|
||||
|
@ -396,11 +370,6 @@ NtUserDestroyCursorIcon(
|
|||
HANDLE Handle,
|
||||
DWORD Unknown);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserDestroyMenu(
|
||||
HMENU hMenu);
|
||||
|
||||
BOOLEAN STDCALL
|
||||
NtUserDestroyWindow(HWND Wnd);
|
||||
|
||||
|
@ -467,35 +436,10 @@ NtUserDrawIconEx(
|
|||
DWORD Unknown0,
|
||||
DWORD Unknown1);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserDrawMenuBarTemp(
|
||||
HWND hWnd,
|
||||
HDC hDC,
|
||||
PRECT hRect,
|
||||
HMENU hMenu,
|
||||
HFONT hFont);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserEmptyClipboard(VOID);
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtUserEnableMenuItem(
|
||||
HMENU hMenu,
|
||||
UINT uIDEnableItem,
|
||||
UINT uEnable);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserInsertMenuItem(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
LPCMENUITEMINFOW lpmii);
|
||||
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserEnableScrollBar(
|
||||
|
@ -509,10 +453,6 @@ NtUserEndDeferWindowPosEx(
|
|||
DWORD Unknown0,
|
||||
DWORD Unknown1);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserEndMenu(VOID);
|
||||
|
||||
BOOL STDCALL
|
||||
NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs);
|
||||
|
||||
|
@ -693,16 +633,17 @@ STDCALL
|
|||
NtUserGetCursorInfo(
|
||||
PCURSORINFO pci);
|
||||
|
||||
UINT STDCALL
|
||||
NtUserGetMenuDefaultItem(
|
||||
HMENU hMenu,
|
||||
UINT fByPos,
|
||||
UINT gmdiFlags);
|
||||
HDC
|
||||
STDCALL
|
||||
NtUserGetDC(
|
||||
HWND hWnd);
|
||||
|
||||
HDC STDCALL
|
||||
NtUserGetDC(HWND hWnd);
|
||||
|
||||
HDC STDCALL NtUserGetDCEx(HWND hWnd, HANDLE hRegion, ULONG Flags);
|
||||
HDC
|
||||
STDCALL
|
||||
NtUserGetDCEx(
|
||||
HWND hWnd,
|
||||
HANDLE hRegion,
|
||||
ULONG Flags);
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
|
@ -782,28 +723,6 @@ STDCALL
|
|||
NtUserGetListBoxInfo(
|
||||
DWORD Unknown0);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetMenuBarInfo(
|
||||
HWND hwnd,
|
||||
LONG idObject,
|
||||
LONG idItem,
|
||||
PMENUBARINFO pmbi);
|
||||
|
||||
UINT
|
||||
STDCALL
|
||||
NtUserGetMenuIndex(
|
||||
HMENU hMenu,
|
||||
UINT wID);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetMenuItemRect(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
LPRECT lprcItem);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetMessage(
|
||||
|
@ -858,12 +777,6 @@ NtUserGetScrollInfo(
|
|||
int fnBar,
|
||||
LPSCROLLINFO lpsi);
|
||||
|
||||
HMENU
|
||||
STDCALL
|
||||
NtUserGetSystemMenu(
|
||||
HWND hWnd,
|
||||
BOOL bRevert);
|
||||
|
||||
HDESK
|
||||
STDCALL
|
||||
NtUserGetThreadDesktop(
|
||||
|
@ -913,14 +826,6 @@ STDCALL
|
|||
NtUserHideCaret(
|
||||
HWND hWnd);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserHiliteMenuItem(
|
||||
HWND hwnd,
|
||||
HMENU hmenu,
|
||||
UINT uItemHilite,
|
||||
UINT uHilite);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserImpersonateDdeClientWindow(
|
||||
|
@ -1024,32 +929,6 @@ NtUserMapVirtualKeyEx( UINT keyCode,
|
|||
DWORD keyboardId,
|
||||
HKL dwhkl );
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserMenuInfo(
|
||||
HMENU hmenu,
|
||||
LPMENUINFO lpmi,
|
||||
BOOL fsog
|
||||
);
|
||||
|
||||
int
|
||||
STDCALL
|
||||
NtUserMenuItemFromPoint(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
DWORD X,
|
||||
DWORD Y);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserMenuItemInfo(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
LPMENUITEMINFOW lpmii,
|
||||
BOOL fsog
|
||||
);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserMessageCall(
|
||||
|
@ -1226,13 +1105,6 @@ NtUserRegisterTasklist(
|
|||
UINT STDCALL
|
||||
NtUserRegisterWindowMessage(PUNICODE_STRING MessageName);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserRemoveMenu(
|
||||
HMENU hMenu,
|
||||
UINT uPosition,
|
||||
UINT uFlags);
|
||||
|
||||
HANDLE STDCALL
|
||||
NtUserRemoveProp(HWND hWnd, ATOM Atom);
|
||||
|
||||
|
@ -1419,31 +1291,6 @@ STDCALL
|
|||
NtUserSetLogonNotifyWindow(
|
||||
DWORD Unknown0);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenu(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
BOOL bRepaint);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenuContextHelpId(
|
||||
HMENU hmenu,
|
||||
DWORD dwContextHelpId);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenuDefaultItem(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
UINT fByPos);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetMenuFlagRtoL(
|
||||
HMENU hMenu);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetObjectInformation(
|
||||
|
@ -1504,12 +1351,6 @@ NtUserSetSystemCursor(
|
|||
HCURSOR hcur,
|
||||
DWORD id);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetSystemMenu(
|
||||
HWND hWnd,
|
||||
HMENU hMenu);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserSetThreadDesktop(
|
||||
|
@ -1653,22 +1494,6 @@ NtUserSystemParametersInfo(
|
|||
PVOID pvParam,
|
||||
UINT fWinIni);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserThunkedMenuInfo(
|
||||
HMENU hMenu,
|
||||
LPCMENUINFO lpcmi);
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserThunkedMenuItemInfo(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
BOOL bInsert,
|
||||
LPMENUITEMINFOW lpmii,
|
||||
PUNICODE_STRING lpszCaption);
|
||||
|
||||
int
|
||||
STDCALL
|
||||
NtUserToUnicodeEx(
|
||||
|
@ -1685,16 +1510,6 @@ STDCALL
|
|||
NtUserTrackMouseEvent(
|
||||
DWORD Unknown0);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserTrackPopupMenuEx(
|
||||
HMENU hmenu,
|
||||
UINT fuFlags,
|
||||
int x,
|
||||
int y,
|
||||
HWND hwnd,
|
||||
LPTPMPARAMS lptpm);
|
||||
|
||||
int
|
||||
STDCALL
|
||||
NtUserTranslateAccelerator(
|
||||
|
@ -1876,13 +1691,6 @@ NtUserSetScrollBarInfo(
|
|||
LONG idObject,
|
||||
SETSCROLLBARINFO *info);
|
||||
|
||||
typedef struct _SETMENUITEMRECT
|
||||
{
|
||||
UINT uItem;
|
||||
BOOL fByPosition;
|
||||
RECT rcRect;
|
||||
} SETMENUITEMRECT, *PSETMENUITEMRECT;
|
||||
|
||||
#endif /* __WIN32K_NTUSER_H */
|
||||
|
||||
/* EOF */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <napi/win32.h>
|
||||
#include <win32k/menu.h>
|
||||
|
||||
#define IS_ATOM(x) \
|
||||
(((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
|
||||
|
@ -27,21 +28,17 @@ typedef struct _MENU_ITEM
|
|||
UNICODE_STRING Text;
|
||||
HBITMAP hbmpItem;
|
||||
RECT Rect;
|
||||
UINT XTab;
|
||||
} MENU_ITEM, *PMENU_ITEM;
|
||||
|
||||
typedef struct _MENU_OBJECT
|
||||
{
|
||||
HANDLE Self;
|
||||
PW32PROCESS W32Process;
|
||||
LIST_ENTRY ListEntry;
|
||||
int MenuItemCount;
|
||||
FAST_MUTEX MenuItemsLock;
|
||||
PMENU_ITEM MenuItemList;
|
||||
MENUINFO MenuInfo;
|
||||
ROSMENUINFO MenuInfo;
|
||||
BOOL RtoL;
|
||||
BOOL IsSystemMenu;
|
||||
BOOL IsMenuBar;
|
||||
int Height;
|
||||
} MENU_OBJECT, *PMENU_OBJECT;
|
||||
|
||||
PMENU_OBJECT FASTCALL
|
||||
|
@ -77,27 +74,17 @@ BOOL FASTCALL
|
|||
IntSetMenuContextHelpId(PMENU_OBJECT MenuObject, DWORD dwContextHelpId);
|
||||
|
||||
BOOL FASTCALL
|
||||
IntGetMenuInfo(PMENU_OBJECT MenuObject, LPMENUINFO lpmi);
|
||||
IntGetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi);
|
||||
|
||||
BOOL FASTCALL
|
||||
IntIsMenu(HMENU hMenu);
|
||||
|
||||
BOOL FASTCALL
|
||||
IntSetMenuInfo(PMENU_OBJECT MenuObject, LPMENUINFO lpmi);
|
||||
IntSetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi);
|
||||
|
||||
int FASTCALL
|
||||
IntGetMenuItemByFlag(PMENU_OBJECT MenuObject, UINT uSearchBy, UINT fFlag,
|
||||
PMENU_ITEM *MenuItem, PMENU_ITEM *PrevMenuItem);
|
||||
|
||||
BOOL FASTCALL
|
||||
IntGetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, LPMENUITEMINFOW lpmii);
|
||||
|
||||
BOOL FASTCALL
|
||||
IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, LPCMENUITEMINFOW lpmii);
|
||||
|
||||
BOOL FASTCALL
|
||||
IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
|
||||
LPCMENUITEMINFOW lpmii);
|
||||
|
||||
UINT FASTCALL
|
||||
IntEnableMenuItem(PMENU_OBJECT MenuObject, UINT uIDEnableItem, UINT uEnable);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: menu.c,v 1.43 2004/01/26 23:22:48 weiden Exp $
|
||||
/* $Id: menu.c,v 1.44 2004/02/15 07:39:12 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -71,6 +71,11 @@
|
|||
} else { \
|
||||
(state) &= ~MFS_DEFAULT; \
|
||||
} \
|
||||
if((change) & MF_MOUSESELECT) { \
|
||||
(state) |= MF_MOUSESELECT; \
|
||||
} else { \
|
||||
(state) &= ~MF_MOUSESELECT; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FreeMenuText(MenuItem) \
|
||||
|
@ -171,7 +176,7 @@ IntFreeMenuItem(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem,
|
|||
if(RemoveFromList)
|
||||
{
|
||||
/* FIXME - Remove from List */
|
||||
MenuObject->MenuItemCount--;
|
||||
MenuObject->MenuInfo.MenuItemCount--;
|
||||
}
|
||||
if(bRecurse && MenuItem->hSubMenu)
|
||||
{
|
||||
|
@ -225,7 +230,7 @@ IntDeleteMenuItems(PMENU_OBJECT MenuObject, BOOL bRecurse)
|
|||
CurItem = NextItem;
|
||||
res++;
|
||||
}
|
||||
MenuObject->MenuItemCount = 0;
|
||||
MenuObject->MenuInfo.MenuItemCount = 0;
|
||||
MenuObject->MenuItemList = NULL;
|
||||
return res;
|
||||
}
|
||||
|
@ -248,7 +253,7 @@ IntDestroyMenuObject(PMENU_OBJECT MenuObject,
|
|||
ExReleaseFastMutexUnsafe(&MenuObject->W32Process->MenuListLock);
|
||||
}
|
||||
|
||||
ObmCloseHandle(MenuObject->W32Process->WindowStation->HandleTable, MenuObject->Self);
|
||||
ObmCloseHandle(MenuObject->W32Process->WindowStation->HandleTable, MenuObject->MenuInfo.Self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -271,8 +276,6 @@ IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
MenuObject->Self = *Handle;
|
||||
MenuObject->IsMenuBar = IsMenuBar;
|
||||
MenuObject->W32Process = Win32Process;
|
||||
MenuObject->RtoL = FALSE; /* default */
|
||||
MenuObject->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
|
||||
|
@ -283,8 +286,16 @@ IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar)
|
|||
NtGdiCreateSolidBrush(RGB(192, 192, 192)); /* FIXME: default background color */
|
||||
MenuObject->MenuInfo.dwContextHelpID = 0; /* default */
|
||||
MenuObject->MenuInfo.dwMenuData = 0; /* default */
|
||||
MenuObject->MenuInfo.Self = *Handle;
|
||||
MenuObject->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
|
||||
MenuObject->MenuInfo.Flags = (IsMenuBar ? 0 : MF_POPUP);
|
||||
MenuObject->MenuInfo.Wnd = NULL;
|
||||
MenuObject->MenuInfo.WndOwner = NULL;
|
||||
MenuObject->MenuInfo.Height = 0;
|
||||
MenuObject->MenuInfo.Width = 0;
|
||||
MenuObject->MenuInfo.TimeToHide = FALSE;
|
||||
|
||||
MenuObject->MenuItemCount = 0;
|
||||
MenuObject->MenuInfo.MenuItemCount = 0;
|
||||
MenuObject->MenuItemList = NULL;
|
||||
ExInitializeFastMutex(&MenuObject->MenuItemsLock);
|
||||
|
||||
|
@ -302,7 +313,7 @@ IntCloneMenuItems(PMENU_OBJECT Destination, PMENU_OBJECT Source)
|
|||
PMENU_ITEM MenuItem, NewMenuItem = NULL;
|
||||
PMENU_ITEM Old = NULL;
|
||||
|
||||
if(!Source->MenuItemCount)
|
||||
if(!Source->MenuInfo.MenuItemCount)
|
||||
return FALSE;
|
||||
|
||||
ExAcquireFastMutexUnsafe(&Destination->MenuItemsLock);
|
||||
|
@ -354,7 +365,7 @@ IntCloneMenuItems(PMENU_OBJECT Destination, PMENU_OBJECT Source)
|
|||
Old->Next = NewMenuItem;
|
||||
else
|
||||
Destination->MenuItemList = NewMenuItem;
|
||||
Destination->MenuItemCount++;
|
||||
Destination->MenuInfo.MenuItemCount++;
|
||||
MenuItem = MenuItem->Next;
|
||||
}
|
||||
|
||||
|
@ -379,7 +390,6 @@ IntCloneMenu(PMENU_OBJECT Source)
|
|||
if(!MenuObject)
|
||||
return NULL;
|
||||
|
||||
MenuObject->Self = Handle;
|
||||
MenuObject->W32Process = Process;
|
||||
MenuObject->RtoL = Source->RtoL;
|
||||
MenuObject->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
|
||||
|
@ -389,8 +399,15 @@ IntCloneMenu(PMENU_OBJECT Source)
|
|||
MenuObject->MenuInfo.hbrBack = Source->MenuInfo.hbrBack;
|
||||
MenuObject->MenuInfo.dwContextHelpID = Source->MenuInfo.dwContextHelpID;
|
||||
MenuObject->MenuInfo.dwMenuData = Source->MenuInfo.dwMenuData;
|
||||
MenuObject->MenuInfo.Self = Handle;
|
||||
MenuObject->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
|
||||
MenuObject->MenuInfo.Wnd = NULL;
|
||||
MenuObject->MenuInfo.WndOwner = NULL;
|
||||
MenuObject->MenuInfo.Height = 0;
|
||||
MenuObject->MenuInfo.Width = 0;
|
||||
MenuObject->MenuInfo.TimeToHide = FALSE;
|
||||
|
||||
MenuObject->MenuItemCount = 0;
|
||||
MenuObject->MenuInfo.MenuItemCount = 0;
|
||||
MenuObject->MenuItemList = NULL;
|
||||
ExInitializeFastMutex(&MenuObject->MenuItemsLock);
|
||||
|
||||
|
@ -419,23 +436,26 @@ IntSetMenuContextHelpId(PMENU_OBJECT MenuObject, DWORD dwContextHelpId)
|
|||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
IntGetMenuInfo(PMENU_OBJECT MenuObject, LPMENUINFO lpmi)
|
||||
IntGetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi)
|
||||
{
|
||||
if(MenuObject)
|
||||
{
|
||||
if(lpmi->fMask & MIM_BACKGROUND)
|
||||
lpmi->hbrBack = MenuObject->MenuInfo.hbrBack;
|
||||
if(lpmi->fMask & MIM_HELPID)
|
||||
lpmi->dwContextHelpID = MenuObject->MenuInfo.dwContextHelpID;
|
||||
if(lpmi->fMask & MIM_MAXHEIGHT)
|
||||
lpmi->cyMax = MenuObject->MenuInfo.cyMax;
|
||||
if(lpmi->fMask & MIM_MENUDATA)
|
||||
lpmi->dwMenuData = MenuObject->MenuInfo.dwMenuData;
|
||||
if(lpmi->fMask & MIM_STYLE)
|
||||
lpmi->dwStyle = MenuObject->MenuInfo.dwStyle;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
if(lpmi->fMask & MIM_BACKGROUND)
|
||||
lpmi->hbrBack = MenuObject->MenuInfo.hbrBack;
|
||||
if(lpmi->fMask & MIM_HELPID)
|
||||
lpmi->dwContextHelpID = MenuObject->MenuInfo.dwContextHelpID;
|
||||
if(lpmi->fMask & MIM_MAXHEIGHT)
|
||||
lpmi->cyMax = MenuObject->MenuInfo.cyMax;
|
||||
if(lpmi->fMask & MIM_MENUDATA)
|
||||
lpmi->dwMenuData = MenuObject->MenuInfo.dwMenuData;
|
||||
if(lpmi->fMask & MIM_STYLE)
|
||||
lpmi->dwStyle = MenuObject->MenuInfo.dwStyle;
|
||||
if (sizeof(MENUINFO) < lpmi->cbSize)
|
||||
{
|
||||
RtlCopyMemory((char *) lpmi + sizeof(MENUINFO),
|
||||
(char *) &MenuObject->MenuInfo + sizeof(MENUINFO),
|
||||
lpmi->cbSize - sizeof(MENUINFO));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -454,7 +474,7 @@ IntIsMenu(HMENU hMenu)
|
|||
|
||||
|
||||
BOOL FASTCALL
|
||||
IntSetMenuInfo(PMENU_OBJECT MenuObject, LPMENUINFO lpmi)
|
||||
IntSetMenuInfo(PMENU_OBJECT MenuObject, PROSMENUINFO lpmi)
|
||||
{
|
||||
if(lpmi->fMask & MIM_BACKGROUND)
|
||||
MenuObject->MenuInfo.hbrBack = lpmi->hbrBack;
|
||||
|
@ -467,9 +487,19 @@ IntSetMenuInfo(PMENU_OBJECT MenuObject, LPMENUINFO lpmi)
|
|||
if(lpmi->fMask & MIM_STYLE)
|
||||
MenuObject->MenuInfo.dwStyle = lpmi->dwStyle;
|
||||
if(lpmi->fMask & MIM_APPLYTOSUBMENUS)
|
||||
{
|
||||
{
|
||||
/* FIXME */
|
||||
}
|
||||
}
|
||||
if (sizeof(MENUINFO) < lpmi->cbSize)
|
||||
{
|
||||
MenuObject->MenuInfo.FocusedItem = lpmi->FocusedItem;
|
||||
MenuObject->MenuInfo.Height = lpmi->Height;
|
||||
MenuObject->MenuInfo.Width = lpmi->Width;
|
||||
MenuObject->MenuInfo.Wnd = lpmi->Wnd;
|
||||
MenuObject->MenuInfo.WndOwner = lpmi->WndOwner;
|
||||
MenuObject->MenuInfo.TimeToHide = lpmi->TimeToHide;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -582,56 +612,86 @@ IntInsertMenuItemToList(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, int pos)
|
|||
MenuItem->Next = NULL;
|
||||
}
|
||||
}
|
||||
MenuObject->MenuItemCount++;
|
||||
MenuObject->MenuInfo.MenuItemCount++;
|
||||
|
||||
return npos;
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
IntGetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, LPMENUITEMINFOW lpmii)
|
||||
IntGetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
|
||||
{
|
||||
if(!MenuItem || !MenuObject || !lpmii)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lpmii->cch = MenuItem->Text.Length;
|
||||
UNICODE_STRING Text;
|
||||
NTSTATUS Status;
|
||||
|
||||
lpmii->cch = MenuItem->Text.Length / sizeof(WCHAR);
|
||||
|
||||
if(lpmii->fMask & MIIM_BITMAP)
|
||||
{
|
||||
lpmii->hbmpItem = MenuItem->hbmpItem;
|
||||
}
|
||||
{
|
||||
lpmii->hbmpItem = MenuItem->hbmpItem;
|
||||
}
|
||||
if(lpmii->fMask & MIIM_CHECKMARKS)
|
||||
{
|
||||
lpmii->hbmpChecked = MenuItem->hbmpChecked;
|
||||
lpmii->hbmpUnchecked = MenuItem->hbmpUnchecked;
|
||||
}
|
||||
{
|
||||
lpmii->hbmpChecked = MenuItem->hbmpChecked;
|
||||
lpmii->hbmpUnchecked = MenuItem->hbmpUnchecked;
|
||||
}
|
||||
if(lpmii->fMask & MIIM_DATA)
|
||||
{
|
||||
lpmii->dwItemData = MenuItem->dwItemData;
|
||||
}
|
||||
{
|
||||
lpmii->dwItemData = MenuItem->dwItemData;
|
||||
}
|
||||
if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
|
||||
{
|
||||
lpmii->fType = MenuItem->fType;
|
||||
}
|
||||
{
|
||||
lpmii->fType = MenuItem->fType;
|
||||
}
|
||||
if(lpmii->fMask & MIIM_ID)
|
||||
{
|
||||
lpmii->wID = MenuItem->wID;
|
||||
}
|
||||
{
|
||||
lpmii->wID = MenuItem->wID;
|
||||
}
|
||||
if(lpmii->fMask & MIIM_STATE)
|
||||
{
|
||||
lpmii->fState = MenuItem->fState;
|
||||
}
|
||||
{
|
||||
lpmii->fState = MenuItem->fState;
|
||||
}
|
||||
if(lpmii->fMask & MIIM_SUBMENU)
|
||||
{
|
||||
lpmii->hSubMenu = MenuItem->hSubMenu;
|
||||
}
|
||||
{
|
||||
lpmii->hSubMenu = MenuItem->hSubMenu;
|
||||
}
|
||||
if (0 != (lpmii->fMask & MIIM_STRING) ||
|
||||
0 != (lpmii->fMask & MIIM_TYPE))
|
||||
{
|
||||
Status = MmCopyFromCaller(&Text, lpmii->dwTypeData, sizeof(UNICODE_STRING));
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
Text.Length = min(Text.MaximumLength, MenuItem->Text.Length);
|
||||
if (0 != Text.Length)
|
||||
{
|
||||
Status = MmCopyToCaller(Text.Buffer, MenuItem->Text.Buffer, Text.Length);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
Status = MmCopyToCaller(lpmii->dwTypeData, &Text, sizeof(UNICODE_STRING));
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
|
||||
{
|
||||
lpmii->Rect = MenuItem->Rect;
|
||||
lpmii->XTab = MenuItem->XTab;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, LPCMENUITEMINFOW lpmii)
|
||||
IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
|
||||
{
|
||||
PUNICODE_STRING Source;
|
||||
UINT copylen = 0;
|
||||
|
@ -710,43 +770,52 @@ IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, LPCMENUITEMINFO
|
|||
{
|
||||
RtlInitUnicodeString(&MenuItem->Text, NULL);
|
||||
}
|
||||
|
||||
if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
|
||||
{
|
||||
MenuItem->Rect = lpmii->Rect;
|
||||
MenuItem->XTab = lpmii->XTab;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL FASTCALL
|
||||
static BOOL FASTCALL
|
||||
IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
|
||||
LPCMENUITEMINFOW lpmii)
|
||||
PROSMENUITEMINFO ItemInfo)
|
||||
{
|
||||
int pos = (int)uItem;
|
||||
PMENU_ITEM MenuItem;
|
||||
|
||||
if(MenuObject->MenuItemCount >= MAX_MENU_ITEMS)
|
||||
{
|
||||
/* FIXME Set last error code? */
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if (MAX_MENU_ITEMS <= MenuObject->MenuInfo.MenuItemCount)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(fByPosition)
|
||||
{
|
||||
/* calculate position */
|
||||
if(pos > MenuObject->MenuItemCount)
|
||||
pos = MenuObject->MenuItemCount;
|
||||
}
|
||||
if (fByPosition)
|
||||
{
|
||||
/* calculate position */
|
||||
if(MenuObject->MenuInfo.MenuItemCount < pos)
|
||||
{
|
||||
pos = MenuObject->MenuInfo.MenuItemCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = IntGetMenuItemByFlag(MenuObject, uItem, MF_BYCOMMAND, NULL, NULL);
|
||||
}
|
||||
if(pos < -1) pos = -1;
|
||||
{
|
||||
pos = IntGetMenuItemByFlag(MenuObject, uItem, MF_BYCOMMAND, NULL, NULL);
|
||||
}
|
||||
if (pos < -1)
|
||||
{
|
||||
pos = -1;
|
||||
}
|
||||
|
||||
MenuItem = ExAllocatePool(PagedPool, sizeof(MENU_ITEM));
|
||||
if(!MenuItem)
|
||||
{
|
||||
/* FIXME Set last error code? */
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if (NULL == MenuItem)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MenuItem->fType = MFT_STRING;
|
||||
MenuItem->fState = MFS_ENABLED | MFS_UNCHECKED;
|
||||
|
@ -758,11 +827,11 @@ IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
|
|||
RtlInitUnicodeString(&MenuItem->Text, NULL);
|
||||
MenuItem->hbmpItem = (HBITMAP)0;
|
||||
|
||||
if(!IntSetMenuItemInfo(MenuObject, MenuItem, lpmii))
|
||||
{
|
||||
ExFreePool(MenuItem);
|
||||
return FALSE;
|
||||
}
|
||||
if (! IntSetMenuItemInfo(MenuObject, MenuItem, ItemInfo))
|
||||
{
|
||||
ExFreePool(MenuItem);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pos = IntInsertMenuItemToList(MenuObject, MenuItem, pos);
|
||||
|
||||
|
@ -1054,7 +1123,7 @@ IntInitTracking(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject, BOOL Popup
|
|||
/* FIXME - send WM_SETCURSOR message */
|
||||
|
||||
if(!(Flags & TPM_NONOTIFY))
|
||||
IntSendMessage(WindowObject->Self, WM_INITMENU, (WPARAM)MenuObject->Self, 0);
|
||||
IntSendMessage(WindowObject->Self, WM_INITMENU, (WPARAM)MenuObject->MenuInfo.Self, 0);
|
||||
}
|
||||
|
||||
VOID FASTCALL
|
||||
|
@ -1164,7 +1233,7 @@ NtUserBuildMenuItemList(
|
|||
}
|
||||
else
|
||||
{
|
||||
res = MenuObject->MenuItemCount;
|
||||
res = MenuObject->MenuInfo.MenuItemCount;
|
||||
}
|
||||
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
|
@ -1313,21 +1382,40 @@ NtUserInsertMenuItem(
|
|||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
LPCMENUITEMINFOW lpmii)
|
||||
LPCMENUITEMINFOW UnsafeItemInfo)
|
||||
{
|
||||
DWORD res = 0;
|
||||
DWORD Res = 0;
|
||||
PMENU_OBJECT MenuObject;
|
||||
NTSTATUS Status;
|
||||
ROSMENUITEMINFO ItemInfo;
|
||||
|
||||
MenuObject = IntGetMenuObject(hMenu);
|
||||
if(!MenuObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
if (ItemInfo.cbSize != sizeof(MENUITEMINFOW))
|
||||
{
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ExAcquireFastMutexUnsafe(&MenuObject->MenuItemsLock);
|
||||
res = IntInsertMenuItem(MenuObject, uItem, fByPosition, lpmii);
|
||||
Res = IntInsertMenuItem(MenuObject, uItem, fByPosition, &ItemInfo);
|
||||
ExReleaseFastMutexUnsafe(&MenuObject->MenuItemsLock);
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
return res;
|
||||
|
||||
return Res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1458,36 +1546,64 @@ NtUserHiliteMenuItem(
|
|||
BOOL
|
||||
STDCALL
|
||||
NtUserMenuInfo(
|
||||
HMENU hmenu,
|
||||
LPMENUINFO lpmi,
|
||||
BOOL fsog)
|
||||
HMENU Menu,
|
||||
PROSMENUINFO UnsafeMenuInfo,
|
||||
BOOL SetOrGet)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
BOOL Res;
|
||||
PMENU_OBJECT MenuObject;
|
||||
|
||||
if(lpmi->cbSize != sizeof(MENUINFO))
|
||||
{
|
||||
/* FIXME - Set Last Error */
|
||||
return FALSE;
|
||||
}
|
||||
MenuObject = IntGetMenuObject(hmenu);
|
||||
if(!MenuObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if(fsog)
|
||||
{
|
||||
/* Set MenuInfo */
|
||||
res = IntSetMenuInfo(MenuObject, lpmi);
|
||||
}
|
||||
DWORD Size;
|
||||
NTSTATUS Status;
|
||||
ROSMENUINFO MenuInfo;
|
||||
|
||||
Status = MmCopyFromCaller(&Size, &UnsafeMenuInfo->cbSize, sizeof(DWORD));
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
if(Size < sizeof(MENUINFO) || sizeof(ROSMENUINFO) < Size)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
Status = MmCopyFromCaller(&MenuInfo, UnsafeMenuInfo, Size);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MenuObject = IntGetMenuObject(Menu);
|
||||
if (NULL == MenuObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(SetOrGet)
|
||||
{
|
||||
/* Set MenuInfo */
|
||||
Res = IntSetMenuInfo(MenuObject, &MenuInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get MenuInfo */
|
||||
res = IntGetMenuInfo(MenuObject, lpmi);
|
||||
}
|
||||
{
|
||||
/* Get MenuInfo */
|
||||
Res = IntGetMenuInfo(MenuObject, &MenuInfo);
|
||||
if (Res)
|
||||
{
|
||||
Status = MmCopyToCaller(UnsafeMenuInfo, &MenuInfo, Size);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
return res;
|
||||
|
||||
return Res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1496,50 +1612,50 @@ NtUserMenuInfo(
|
|||
*/
|
||||
int STDCALL
|
||||
NtUserMenuItemFromPoint(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
HWND Wnd,
|
||||
HMENU Menu,
|
||||
DWORD X,
|
||||
DWORD Y)
|
||||
{
|
||||
PMENU_OBJECT MenuObject;
|
||||
PWINDOW_OBJECT WindowObject;
|
||||
PWINDOW_OBJECT WindowObject = NULL;
|
||||
PMENU_ITEM mi;
|
||||
int i;
|
||||
|
||||
MenuObject = IntGetMenuObject(hMenu);
|
||||
if(!MenuObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return -1;
|
||||
}
|
||||
if(hWnd)
|
||||
{
|
||||
WindowObject = IntGetWindowObject(hWnd);
|
||||
if(!WindowObject)
|
||||
MenuObject = IntGetMenuObject(Menu);
|
||||
if (NULL == MenuObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (0 != (MenuObject->MenuInfo.Flags & MF_POPUP))
|
||||
{
|
||||
WindowObject = IntGetWindowObject(MenuObject->MenuInfo.Wnd);
|
||||
if (NULL == WindowObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||
return -1;
|
||||
}
|
||||
X -= WindowObject->WindowRect.left;
|
||||
Y -= WindowObject->WindowRect.top;
|
||||
IntReleaseWindowObject(WindowObject);
|
||||
}
|
||||
|
||||
ExAcquireFastMutexUnsafe(&MenuObject->MenuItemsLock);
|
||||
mi = MenuObject->MenuItemList;
|
||||
for(i = 0; mi; i++)
|
||||
{
|
||||
if(InRect(mi->Rect, X, Y))
|
||||
for (i = 0; NULL != mi; i++)
|
||||
{
|
||||
break;
|
||||
if (InRect(mi->Rect, X, Y))
|
||||
{
|
||||
break;
|
||||
}
|
||||
mi = mi->Next;
|
||||
}
|
||||
mi = mi->Next;
|
||||
}
|
||||
ExReleaseFastMutexUnsafe(&MenuObject->MenuItemsLock);
|
||||
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
|
||||
if(hWnd)
|
||||
IntReleaseWindowObject(WindowObject);
|
||||
|
||||
return (mi ? i : -1);
|
||||
return (mi ? i : NO_SELECTED_ITEM);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1549,49 +1665,76 @@ NtUserMenuItemFromPoint(
|
|||
BOOL
|
||||
STDCALL
|
||||
NtUserMenuItemInfo(
|
||||
HMENU hMenu,
|
||||
UINT uItem,
|
||||
BOOL fByPosition,
|
||||
LPMENUITEMINFOW lpmii,
|
||||
BOOL fsog)
|
||||
HMENU Menu,
|
||||
UINT Item,
|
||||
BOOL ByPosition,
|
||||
PROSMENUITEMINFO UnsafeItemInfo,
|
||||
BOOL SetOrGet)
|
||||
{
|
||||
PMENU_OBJECT MenuObject;
|
||||
PMENU_ITEM MenuItem;
|
||||
MENUITEMINFOW Safemii;
|
||||
ROSMENUITEMINFO ItemInfo;
|
||||
NTSTATUS Status;
|
||||
UINT Size;
|
||||
BOOL Ret;
|
||||
|
||||
MenuObject = IntGetMenuObject(hMenu);
|
||||
if(!MenuObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(fsog)
|
||||
{
|
||||
/* Set menu item info */
|
||||
}
|
||||
else
|
||||
{
|
||||
if((IntGetMenuItemByFlag(MenuObject, uItem, (fByPosition ? MF_BYPOSITION : MF_BYCOMMAND),
|
||||
&MenuItem, NULL) > -1) &&
|
||||
IntGetMenuItemInfo(MenuObject, MenuItem, &Safemii))
|
||||
MenuObject = IntGetMenuObject(Menu);
|
||||
if (NULL == MenuObject)
|
||||
{
|
||||
Status = MmCopyToCaller(lpmii, &Safemii, sizeof(MENUITEMINFOW));
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
return TRUE;
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
Status = MmCopyFromCaller(&Size, &UnsafeItemInfo->cbSize, sizeof(UINT));
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
if(sizeof(MENUITEMINFOW) != Size && sizeof(ROSMENUITEMINFO) != Size)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, Size);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (IntGetMenuItemByFlag(MenuObject, Item,
|
||||
(ByPosition ? MF_BYPOSITION : MF_BYCOMMAND),
|
||||
&MenuItem, NULL) < 0)
|
||||
{
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (SetOrGet)
|
||||
{
|
||||
Ret = IntSetMenuItemInfo(MenuObject, MenuItem, &ItemInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ret = IntGetMenuItemInfo(MenuObject, MenuItem, &ItemInfo);
|
||||
if (Ret)
|
||||
{
|
||||
Status = MmCopyToCaller(UnsafeItemInfo, &ItemInfo, Size);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
return FALSE;
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: misc.c,v 1.48 2004/01/31 14:57:58 rcampbell Exp $
|
||||
/* $Id: misc.c,v 1.49 2004/02/15 07:39:12 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -205,11 +205,11 @@ NtUserCallTwoParam(
|
|||
|
||||
if(Param2 > 0)
|
||||
{
|
||||
Ret = (MenuObject->Height == (int)Param2);
|
||||
MenuObject->Height = (int)Param2;
|
||||
Ret = (MenuObject->MenuInfo.Height == (int)Param2);
|
||||
MenuObject->MenuInfo.Height = (int)Param2;
|
||||
}
|
||||
else
|
||||
Ret = (DWORD)MenuObject->Height;
|
||||
Ret = (DWORD)MenuObject->MenuInfo.Height;
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
return Ret;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: window.c,v 1.182 2004/02/08 10:53:17 navaraf Exp $
|
||||
/* $Id: window.c,v 1.183 2004/02/15 07:39:12 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -432,6 +432,70 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static BOOL FASTCALL
|
||||
IntSetMenu(
|
||||
PWINDOW_OBJECT WindowObject,
|
||||
HMENU Menu,
|
||||
BOOL *Changed)
|
||||
{
|
||||
PMENU_OBJECT OldMenuObject, NewMenuObject;
|
||||
|
||||
*Changed = (WindowObject->IDMenu != (UINT) Menu);
|
||||
if (! *Changed)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (0 != WindowObject->IDMenu)
|
||||
{
|
||||
OldMenuObject = IntGetMenuObject((HMENU) WindowObject->IDMenu);
|
||||
ASSERT(NULL == OldMenuObject || OldMenuObject->MenuInfo.Wnd == WindowObject->Self);
|
||||
}
|
||||
else
|
||||
{
|
||||
OldMenuObject = NULL;
|
||||
}
|
||||
|
||||
if (NULL != Menu)
|
||||
{
|
||||
NewMenuObject = IntGetMenuObject(Menu);
|
||||
if (NULL == NewMenuObject)
|
||||
{
|
||||
if (NULL != OldMenuObject)
|
||||
{
|
||||
IntReleaseMenuObject(OldMenuObject);
|
||||
}
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
if (NULL != NewMenuObject->MenuInfo.Wnd)
|
||||
{
|
||||
/* Can't use the same menu for two windows */
|
||||
if (NULL != OldMenuObject)
|
||||
{
|
||||
IntReleaseMenuObject(OldMenuObject);
|
||||
}
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WindowObject->IDMenu = (UINT) Menu;
|
||||
if (NULL != NewMenuObject)
|
||||
{
|
||||
NewMenuObject->MenuInfo.Wnd = WindowObject->Self;
|
||||
IntReleaseMenuObject(NewMenuObject);
|
||||
}
|
||||
if (NULL != OldMenuObject)
|
||||
{
|
||||
OldMenuObject->MenuInfo.Wnd = NULL;
|
||||
IntReleaseMenuObject(OldMenuObject);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* INTERNAL ******************************************************************/
|
||||
|
||||
|
@ -557,8 +621,8 @@ IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu)
|
|||
NewMenuObject = IntCloneMenu(MenuObject);
|
||||
if(NewMenuObject)
|
||||
{
|
||||
WindowObject->SystemMenu = NewMenuObject->Self;
|
||||
NewMenuObject->IsSystemMenu = TRUE;
|
||||
WindowObject->SystemMenu = NewMenuObject->MenuInfo.Self;
|
||||
NewMenuObject->MenuInfo.Flags |= MF_SYSMENU;
|
||||
ret = NewMenuObject;
|
||||
//IntReleaseMenuObject(NewMenuObject);
|
||||
}
|
||||
|
@ -576,8 +640,8 @@ IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu)
|
|||
NewMenuObject = IntCloneMenu(MenuObject);
|
||||
if(NewMenuObject)
|
||||
{
|
||||
WindowObject->SystemMenu = NewMenuObject->Self;
|
||||
NewMenuObject->IsSystemMenu = TRUE;
|
||||
WindowObject->SystemMenu = NewMenuObject->MenuInfo.Self;
|
||||
NewMenuObject->MenuInfo.Flags |= MF_SYSMENU;
|
||||
ret = NewMenuObject;
|
||||
//IntReleaseMenuObject(NewMenuObject);
|
||||
}
|
||||
|
@ -726,6 +790,7 @@ IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
|
|||
PWINDOW_OBJECT WndOldParent;
|
||||
HWND hWnd, hWndNewParent, hWndOldParent;
|
||||
BOOL WasVisible;
|
||||
BOOL MenuChanged;
|
||||
|
||||
hWnd = Wnd->Self;
|
||||
hWndNewParent = WndNewParent->Self;
|
||||
|
@ -757,7 +822,7 @@ IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
|
|||
if (!(Wnd->Style & WS_CHILD))
|
||||
{
|
||||
//if ( Wnd->Menu ) DestroyMenu ( Wnd->menu );
|
||||
Wnd->IDMenu = 0;
|
||||
IntSetMenu(Wnd, NULL, &MenuChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +856,7 @@ IntSetSystemMenu(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject)
|
|||
OldMenuObject = IntGetMenuObject(WindowObject->SystemMenu);
|
||||
if(OldMenuObject)
|
||||
{
|
||||
OldMenuObject->IsSystemMenu = FALSE;
|
||||
OldMenuObject->MenuInfo.Flags &= ~ MF_SYSMENU;
|
||||
IntReleaseMenuObject(OldMenuObject);
|
||||
}
|
||||
}
|
||||
|
@ -799,8 +864,8 @@ IntSetSystemMenu(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject)
|
|||
if(MenuObject)
|
||||
{
|
||||
/* FIXME check window style, propably return FALSE ? */
|
||||
WindowObject->SystemMenu = MenuObject->Self;
|
||||
MenuObject->IsSystemMenu = TRUE;
|
||||
WindowObject->SystemMenu = MenuObject->MenuInfo.Self;
|
||||
MenuObject->MenuInfo.Flags |= MF_SYSMENU;
|
||||
}
|
||||
else
|
||||
WindowObject->SystemMenu = (HMENU)0;
|
||||
|
@ -1096,6 +1161,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
|
|||
CREATESTRUCTW Cs;
|
||||
CBT_CREATEWNDW CbtCreate;
|
||||
LRESULT Result;
|
||||
BOOL MenuChanged;
|
||||
|
||||
DPRINT("NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight);
|
||||
|
||||
|
@ -1211,9 +1277,10 @@ NtUserCreateWindowEx(DWORD dwExStyle,
|
|||
|
||||
WindowObject->SystemMenu = (HMENU)0;
|
||||
WindowObject->ContextHelpId = 0;
|
||||
WindowObject->IDMenu = (UINT)hMenu;
|
||||
WindowObject->IDMenu = 0;
|
||||
WindowObject->Instance = hInstance;
|
||||
WindowObject->Self = Handle;
|
||||
IntSetMenu(WindowObject, hMenu, &MenuChanged);
|
||||
WindowObject->MessageQueue = PsGetWin32Thread()->MessageQueue;
|
||||
WindowObject->Parent = ParentWindow;
|
||||
WindowObject->Owner = IntGetWindowObject(OwnerWindowHandle);
|
||||
|
@ -1275,7 +1342,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
|
|||
SystemMenu = IntGetSystemMenu(WindowObject, TRUE, TRUE);
|
||||
if(SystemMenu)
|
||||
{
|
||||
WindowObject->SystemMenu = SystemMenu->Self;
|
||||
WindowObject->SystemMenu = SystemMenu->MenuInfo.Self;
|
||||
IntReleaseMenuObject(SystemMenu);
|
||||
}
|
||||
}
|
||||
|
@ -3038,53 +3105,35 @@ NtUserSetLogonNotifyWindow(DWORD Unknown0)
|
|||
*/
|
||||
BOOL STDCALL
|
||||
NtUserSetMenu(
|
||||
HWND hWnd,
|
||||
HMENU hMenu,
|
||||
BOOL bRepaint)
|
||||
HWND Wnd,
|
||||
HMENU Menu,
|
||||
BOOL Repaint)
|
||||
{
|
||||
PWINDOW_OBJECT WindowObject;
|
||||
PMENU_OBJECT MenuObject;
|
||||
BOOL Changed = FALSE;
|
||||
PWINDOW_OBJECT WindowObject;
|
||||
BOOL Changed;
|
||||
|
||||
WindowObject = IntGetWindowObject((HWND)hWnd);
|
||||
if (!WindowObject)
|
||||
{
|
||||
WindowObject = IntGetWindowObject((HWND) Wnd);
|
||||
if (NULL == WindowObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (hMenu)
|
||||
{
|
||||
/* assign new menu handle */
|
||||
MenuObject = IntGetMenuObject((HWND)hMenu);
|
||||
if (!MenuObject)
|
||||
{
|
||||
IntReleaseWindowObject(WindowObject);
|
||||
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Changed = (WindowObject->IDMenu != (UINT)hMenu);
|
||||
WindowObject->IDMenu = (UINT)hMenu;
|
||||
|
||||
IntReleaseMenuObject(MenuObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* remove the menu handle */
|
||||
Changed = (WindowObject->IDMenu != 0);
|
||||
WindowObject->IDMenu = 0;
|
||||
}
|
||||
if (! IntSetMenu(WindowObject, Menu, &Changed))
|
||||
{
|
||||
IntReleaseWindowObject(WindowObject);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IntReleaseWindowObject(WindowObject);
|
||||
IntReleaseWindowObject(WindowObject);
|
||||
|
||||
if (Changed && bRepaint)
|
||||
{
|
||||
WinPosSetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
|
||||
if (Changed && Repaint)
|
||||
{
|
||||
WinPosSetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
|
||||
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue