ReactOS 0.4.15-dev-5664-g3bf4ef6
menu.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagMENUSTATE
 
struct  _SETMENUITEMRECT
 
struct  tagROSMENUINFO
 
struct  tagROSMENUITEMINFO
 

Macros

#define IS_ATOM(x)    (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
 
#define MENU_ITEM_TYPE(flags)    ((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR))
 
#define MF_END   (0x0080)
 
#define IntReleaseMenuObject(MenuObj)    UserDereferenceObject(MenuObj)
 

Typedefs

typedef struct tagMENUSTATE MENUSTATE
 
typedef struct tagMENUSTATEPMENUSTATE
 
typedef struct _SETMENUITEMRECT SETMENUITEMRECT
 
typedef struct _SETMENUITEMRECTPSETMENUITEMRECT
 
typedef struct tagROSMENUINFO ROSMENUINFO
 
typedef struct tagROSMENUINFOPROSMENUINFO
 
typedef struct tagROSMENUITEMINFO ROSMENUITEMINFO
 
typedef struct tagROSMENUITEMINFOPROSMENUITEMINFO
 

Functions

BOOL FASTCALL IntIsMenu (HMENU)
 
PMENU FASTCALL IntGetMenuObject (HMENU hMenu)
 
BOOLEAN UserDestroyMenuObject (PVOID Object)
 
BOOL FASTCALL IntDestroyMenuObject (PMENU MenuObject, BOOL bRecurse)
 
PMENU FASTCALL IntCloneMenu (PMENU Source)
 
int FASTCALL IntGetMenuItemByFlag (PMENU MenuObject, UINT uSearchBy, UINT fFlag, PMENU *SubMenu, PITEM *MenuItem, PITEM *PrevMenuItem)
 
BOOL FASTCALL IntCleanupMenus (struct _EPROCESS *Process, PPROCESSINFO Win32Process)
 
BOOL FASTCALL IntInsertMenuItem (_In_ PMENU MenuObject, UINT uItem, BOOL fByPosition, PROSMENUITEMINFO ItemInfo, PUNICODE_STRING lpstr)
 
PMENU FASTCALL IntGetSystemMenu (PWND Window, BOOL bRevert)
 
UINT FASTCALL IntFindSubMenu (HMENU *hMenu, HMENU hSubTarget)
 
UINT FASTCALL IntGetMenuState (HMENU hMenu, UINT uId, UINT uFlags)
 
BOOL FASTCALL IntRemoveMenuItem (PMENU Menu, UINT uPosition, UINT uFlags, BOOL bRecurse)
 
PITEM FASTCALL MENU_FindItem (PMENU *pmenu, UINT *nPos, UINT wFlags)
 
BOOL FASTCALL IntMenuItemInfo (PMENU Menu, UINT Item, BOOL ByPosition, PROSMENUITEMINFO UnsafeItemInfo, BOOL SetOrGet, PUNICODE_STRING lpstr)
 
BOOL FASTCALL IntSetMenu (PWND Wnd, HMENU Menu, BOOL *Changed)
 
UINT MENU_DrawMenuBar (HDC hDC, LPRECT lprect, PWND pWnd, BOOL suppress_draw)
 
BOOL MenuInit (VOID)
 
VOID MENU_TrackKbdMenuBar (PWND pwnd, UINT wParam, WCHAR wChar)
 
VOID MENU_TrackMouseMenuBar (PWND pWnd, ULONG ht, POINT pt)
 
BOOL WINAPI PopupMenuWndProc (PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
 
BOOL FASTCALL IntSetMenuItemInfo (PMENU, PITEM, PROSMENUITEMINFO, PUNICODE_STRING)
 
PWND MENU_IsMenuActive (VOID)
 
void MENU_EndMenu (PWND pwnd)
 
void FASTCALL MENU_InitSysMenuPopup (PMENU menu, DWORD style, DWORD clsStyle, LONG HitTest)
 
INT FASTCALL IntMenuItemFromPoint (PWND pWnd, HMENU hMenu, POINT ptScreen)
 
BOOL WINAPI IntTrackPopupMenuEx (PMENU menu, UINT wFlags, int x, int y, PWND pWnd, LPTPMPARAMS lpTpm)
 

Macro Definition Documentation

◆ IntReleaseMenuObject

#define IntReleaseMenuObject (   MenuObj)     UserDereferenceObject(MenuObj)

Definition at line 130 of file menu.h.

◆ IS_ATOM

#define IS_ATOM (   x)     (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))

Definition at line 3 of file menu.h.

◆ MENU_ITEM_TYPE

#define MENU_ITEM_TYPE (   flags)     ((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR))

Definition at line 6 of file menu.h.

◆ MF_END

#define MF_END   (0x0080)

Definition at line 10 of file menu.h.

Typedef Documentation

◆ MENUSTATE

◆ PMENUSTATE

◆ PROSMENUINFO

◆ PROSMENUITEMINFO

◆ PSETMENUITEMRECT

◆ ROSMENUINFO

◆ ROSMENUITEMINFO

◆ SETMENUITEMRECT

Function Documentation

◆ IntCleanupMenus()

BOOL FASTCALL IntCleanupMenus ( struct _EPROCESS Process,
PPROCESSINFO  Win32Process 
)

◆ IntCloneMenu()

PMENU FASTCALL IntCloneMenu ( PMENU  Source)

Definition at line 824 of file menu.c.

825{
826 HANDLE hMenu;
827 PMENU Menu;
828
829 if(!Source)
830 return NULL;
831
832 /* A menu is valid process wide. We can pass to the object manager any thread ptr */
834 Source->head.rpdesk,
835 ((PPROCESSINFO)Source->head.hTaskWow)->ptiList,
836 &hMenu,
837 TYPE_MENU,
838 sizeof(MENU));
839 if(!Menu)
840 return NULL;
841
842 Menu->fFlags = Source->fFlags;
843 Menu->cyMax = Source->cyMax;
844 Menu->hbrBack = Source->hbrBack;
845 Menu->dwContextHelpId = Source->dwContextHelpId;
846 Menu->dwMenuData = Source->dwMenuData;
847 Menu->iItem = NO_SELECTED_ITEM;
848 Menu->spwndNotify = NULL;
849 Menu->cyMenu = 0;
850 Menu->cxMenu = 0;
851 Menu->cItems = 0;
852 Menu->iTop = 0;
853 Menu->iMaxTop = 0;
854 Menu->cxTextAlign = 0;
855 Menu->rgItems = NULL;
856
857 Menu->hWnd = NULL;
858 Menu->TimeToHide = FALSE;
859
861
862 return Menu;
863}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
struct tagMENU MENU
@ TYPE_MENU
Definition: ntuser.h:42
#define NO_SELECTED_ITEM
Definition: ntuser.h:408
struct tagMENU * PMENU
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
ULONG fFlags
Definition: ntuser.h:413
ULONG cyMenu
Definition: ntuser.h:418
struct _WND * spwndNotify
Definition: ntuser.h:420
INT iItem
Definition: ntuser.h:414
UINT cItems
Definition: ntuser.h:416
DWORD dwContextHelpId
Definition: ntuser.h:423
BOOL TimeToHide
Definition: ntuser.h:433
DWORD_PTR dwMenuData
Definition: ntuser.h:425
HWND hWnd
Definition: ntuser.h:432
ULONG cxMenu
Definition: ntuser.h:417
ULONG cyMax
Definition: ntuser.h:424
INT iTop
Definition: ntuser.h:427
INT iMaxTop
Definition: ntuser.h:428
HBRUSH hbrBack
Definition: ntuser.h:426
ULONG cxTextAlign
Definition: ntuser.h:419
PITEM rgItems
Definition: ntuser.h:421
BOOL FASTCALL IntCloneMenuItems(PMENU Destination, PMENU Source)
Definition: menu.c:773
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568

Referenced by MENU_GetSystemMenu().

◆ IntDestroyMenuObject()

BOOL FASTCALL IntDestroyMenuObject ( PMENU  MenuObject,
BOOL  bRecurse 
)

Definition at line 319 of file menu.c.

320{
322 if (Menu)
323 {
324 PWND Window;
325
326 if (PsGetCurrentProcessSessionId() == Menu->head.rpdesk->rpwinstaParent->dwSessionId)
327 {
328 BOOL ret;
329 if (Menu->hWnd)
330 {
331 Window = ValidateHwndNoErr(Menu->hWnd);
332 if (Window)
333 {
334 //Window->IDMenu = 0; Only in Win9x!! wine win test_SetMenu test...
335
336 /* DestroyMenu should not destroy system menu popup owner */
337 if ((Menu->fFlags & (MNF_POPUP | MNF_SYSSUBMENU)) == MNF_POPUP)
338 {
339 // Should we check it to see if it has Class?
340 ERR("FIXME Pop up menu window thing'ie\n");
341 //co_UserDestroyWindow( Window );
342 //Menu->hWnd = 0;
343 }
344 }
345 }
346
347 if (!UserMarkObjectDestroy(Menu)) return TRUE;
348
349 /* Remove all menu items */
350 IntDestroyMenu( Menu, bRecurse);
351
352 ret = UserDeleteObject(Menu->head.h, TYPE_MENU);
353 TRACE("IntDestroyMenuObject %d\n",ret);
354 return ret;
355 }
356 }
357 return FALSE;
358}
#define ERR(fmt,...)
Definition: debug.h:110
#define TRUE
Definition: types.h:120
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MNF_SYSSUBMENU
Definition: ntuser.h:403
#define MNF_POPUP
Definition: ntuser.h:397
#define ASSERT(a)
Definition: mode.c:44
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:227
#define TRACE(s)
Definition: solgame.cpp:4
Definition: window.c:28
Definition: ntuser.h:689
int ret
BOOL IntDestroyMenu(PMENU pMenu, BOOL bRecurse)
Definition: menu.c:271
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
Definition: object.c:621
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717

Referenced by co_UserFreeWindow(), IntDestroyMenu(), IntGetSystemMenu(), IntRemoveMenuItem(), IntSetMenuItemInfo(), IntSetSystemMenu(), MENU_GetSystemMenu(), NtUserDestroyMenu(), UserDestroyMenu(), and UserDestroyMenuObject().

◆ IntFindSubMenu()

UINT FASTCALL IntFindSubMenu ( HMENU hMenu,
HMENU  hSubTarget 
)

Definition at line 5015 of file menu.c.

5016{
5017 PMENU menu, pSubTarget;
5018 UINT Pos;
5019 if (((*hMenu)==(HMENU)0xffff) ||(!(menu = UserGetMenuObject(*hMenu))))
5020 return NO_SELECTED_ITEM;
5021
5022 pSubTarget = UserGetMenuObject(hSubTarget);
5023
5024 Pos = MENU_FindSubMenu(&menu, pSubTarget );
5025
5026 *hMenu = (menu ? UserHMGetHandle(menu) : NULL);
5027
5028 return Pos;
5029}
ush Pos
Definition: deflate.h:92
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
unsigned int UINT
Definition: ndis.h:50
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:4
static UINT FASTCALL MENU_FindSubMenu(PMENU *menu, PMENU SubTarget)
Definition: menu.c:566

Referenced by co_IntTranslateAccelerator().

◆ IntGetMenuItemByFlag()

int FASTCALL IntGetMenuItemByFlag ( PMENU  MenuObject,
UINT  uSearchBy,
UINT  fFlag,
PMENU SubMenu,
PITEM MenuItem,
PITEM PrevMenuItem 
)

◆ IntGetMenuObject()

PMENU FASTCALL IntGetMenuObject ( HMENU  hMenu)

Definition at line 194 of file menu.c.

195{
196 PMENU Menu = UserGetMenuObject(hMenu);
197 if (Menu)
198 Menu->head.cLockObj++;
199
200 return Menu;
201}
PROCDESKHEAD head
Definition: ntuser.h:412

Referenced by IntSetMenu(), NtUserCallTwoParam(), and NtUserSetSystemMenu().

◆ IntGetMenuState()

UINT FASTCALL IntGetMenuState ( HMENU  hMenu,
UINT  uId,
UINT  uFlags 
)

Definition at line 4975 of file menu.c.

4976{
4977 PMENU MenuObject;
4978 PITEM pItem;
4979
4980 if (!(MenuObject = UserGetMenuObject(hMenu)))
4981 {
4982 return (UINT)-1;
4983 }
4984
4985 if (!(pItem = MENU_FindItem( &MenuObject, &uId, uFlags ))) return -1;
4986
4987 if (pItem->spSubMenu)
4988 {
4989 return (pItem->spSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|MF_POPUP) & 0xff);
4990 }
4991 else
4992 return (pItem->fType | pItem->fState);
4993}
UINT uFlags
Definition: api.c:59
UINT fType
Definition: ntuser.h:367
UINT fState
Definition: ntuser.h:368
struct tagMENU * spSubMenu
Definition: ntuser.h:370
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:509
#define MF_POPUP
Definition: winuser.h:136

Referenced by co_IntTranslateAccelerator(), NC_DoButton(), NC_HandleNCLButtonDblClk(), and UserDrawCaptionButton().

◆ IntGetSystemMenu()

PMENU FASTCALL IntGetSystemMenu ( PWND  Window,
BOOL  bRevert 
)

Definition at line 5383 of file menu.c.

5384{
5385 PMENU Menu;
5386
5387 if (bRevert)
5388 {
5389 if (Window->SystemMenu)
5390 {
5391 Menu = UserGetMenuObject(Window->SystemMenu);
5392 if (Menu && !(Menu->fFlags & MNF_SYSDESKMN))
5393 {
5395 Window->SystemMenu = NULL;
5396 }
5397 }
5398 }
5399 else
5400 {
5401 Menu = Window->SystemMenu ? UserGetMenuObject(Window->SystemMenu) : NULL;
5402 if ((!Menu || Menu->fFlags & MNF_SYSDESKMN) && Window->style & WS_SYSMENU)
5403 {
5405 Window->SystemMenu = Menu ? UserHMGetHandle(Menu) : NULL;
5406 }
5407 }
5408
5409 if (Window->SystemMenu)
5410 {
5411 HMENU hMenu = IntGetSubMenu( Window->SystemMenu, 0);
5412 /* Store the dummy sysmenu handle to facilitate the refresh */
5413 /* of the close button if the SC_CLOSE item change */
5414 Menu = UserGetMenuObject(hMenu);
5415 if (Menu)
5416 {
5417 Menu->spwndNotify = Window;
5418 Menu->fFlags |= MNF_SYSSUBMENU;
5419 }
5420 return Menu;
5421 }
5422 return NULL;
5423}
#define MNF_SYSDESKMN
Definition: ntuser.h:402
#define WS_SYSMENU
Definition: pedump.c:629
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:319
PMENU FASTCALL MENU_GetSystemMenu(PWND Window, PMENU Popup)
Definition: menu.c:5278
HMENU FASTCALL IntGetSubMenu(HMENU hMenu, int nPos)
Definition: menu.c:4995

Referenced by IntDefWindowProc(), MENU_TrackMouseMenuBar(), NC_DoButton(), NC_HandleNCLButtonDblClk(), NC_HandleNCRButtonDown(), NtUserGetMenuBarInfo(), NtUserGetSystemMenu(), and UserDrawCaptionButton().

◆ IntInsertMenuItem()

BOOL FASTCALL IntInsertMenuItem ( _In_ PMENU  MenuObject,
UINT  uItem,
BOOL  fByPosition,
PROSMENUITEMINFO  ItemInfo,
PUNICODE_STRING  lpstr 
)

Definition at line 693 of file menu.c.

699{
700 PITEM MenuItem;
701 PMENU SubMenu = NULL;
702
703 NT_ASSERT(MenuObject != NULL);
704
705 if (MAX_MENU_ITEMS <= MenuObject->cItems)
706 {
708 return FALSE;
709 }
710
711 SubMenu = MenuObject;
712
713 if(!(MenuItem = MENU_InsertItem( SubMenu, uItem, fByPosition ? MF_BYPOSITION : MF_BYCOMMAND, &SubMenu, &uItem ))) return FALSE;
714
715 if(!IntSetMenuItemInfo(SubMenu, MenuItem, ItemInfo, lpstr))
716 {
717 IntRemoveMenuItem(SubMenu, uItem, fByPosition ? MF_BYPOSITION : MF_BYCOMMAND, FALSE);
718 return FALSE;
719 }
720
721 /* Force size recalculation! */
722 SubMenu->cyMenu = 0;
723 MenuItem->hbmpChecked = MenuItem->hbmpUnchecked = 0;
724
725 TRACE("IntInsertMenuItemToList = %u %i\n", uItem, (BOOL)((INT)uItem >= 0));
726
727 return TRUE;
728}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static LPCSTR lpstr
Definition: font.c:51
HANDLE hbmpChecked
Definition: ntuser.h:371
HANDLE hbmpUnchecked
Definition: ntuser.h:372
int32_t INT
Definition: typedefs.h:58
BOOL FASTCALL IntSetMenuItemInfo(PMENU MenuObject, PITEM MenuItem, PROSMENUITEMINFO lpmii, PUNICODE_STRING lpstr)
Definition: menu.c:1035
BOOL FASTCALL IntRemoveMenuItem(PMENU pMenu, UINT nPos, UINT wFlags, BOOL bRecurse)
Definition: menu.c:598
ITEM * MENU_InsertItem(PMENU menu, UINT pos, UINT flags, PMENU *submenu, UINT *npos)
Definition: menu.c:641
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
#define MF_BYCOMMAND
Definition: winuser.h:202
#define MF_BYPOSITION
Definition: winuser.h:203
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by MENU_GetSystemMenu(), and UserInsertMenuItem().

◆ IntIsMenu()

BOOL FASTCALL IntIsMenu ( HMENU  Menu)

Definition at line 242 of file menu.c.

243{
244 if (UserGetMenuObject(Menu)) return TRUE;
245 return FALSE;
246}

◆ IntMenuItemFromPoint()

INT FASTCALL IntMenuItemFromPoint ( PWND  pWnd,
HMENU  hMenu,
POINT  ptScreen 
)

Definition at line 1520 of file menu.c.

1521{
1522 MENU *menu = UserGetMenuObject(hMenu);
1523 UINT pos;
1524
1525 /*FIXME: Do we have to handle hWnd here? */
1526 if (!menu) return -1;
1527 if (!MENU_FindItemByCoords(menu, ptScreen, &pos)) return -1;
1528 return pos;
1529}
static ITEM * MENU_FindItemByCoords(MENU *menu, POINT pt, UINT *pos)
Definition: menu.c:1482

Referenced by IntDefWindowProc().

◆ IntMenuItemInfo()

BOOL FASTCALL IntMenuItemInfo ( PMENU  Menu,
UINT  Item,
BOOL  ByPosition,
PROSMENUITEMINFO  UnsafeItemInfo,
BOOL  SetOrGet,
PUNICODE_STRING  lpstr 
)

Definition at line 5076 of file menu.c.

5083{
5084 PITEM MenuItem;
5085 BOOL Ret;
5086
5087 if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5088 {
5090 return( FALSE);
5091 }
5092 if (SetOrGet)
5093 {
5094 Ret = IntSetMenuItemInfo(Menu, MenuItem, ItemInfo, lpstr);
5095 }
5096 else
5097 {
5098 Ret = IntGetMenuItemInfo(Menu, MenuItem, ItemInfo);
5099 }
5100 return( Ret);
5101}
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
BOOL FASTCALL IntGetMenuItemInfo(PMENU Menu, PITEM MenuItem, PROSMENUITEMINFO lpmii)
Definition: menu.c:964
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937

Referenced by MENU_GetSystemMenu().

◆ IntRemoveMenuItem()

BOOL FASTCALL IntRemoveMenuItem ( PMENU  Menu,
UINT  uPosition,
UINT  uFlags,
BOOL  bRecurse 
)

Definition at line 598 of file menu.c.

599{
600 PITEM item;
601 PITEM newItems;
602
603 TRACE("(menu=%p pos=%04x flags=%04x)\n",pMenu, nPos, wFlags);
604 if (!(item = MENU_FindItem( &pMenu, &nPos, wFlags ))) return FALSE;
605
606 /* Remove item */
607
608 FreeMenuText(pMenu,item);
609 if (bRecurse && item->spSubMenu)
610 {
611 IntDestroyMenuObject(item->spSubMenu, bRecurse);
612 }
614 if (--pMenu->cItems == 0)
615 {
616 DesktopHeapFree(pMenu->head.rpdesk, pMenu->rgItems );
617 pMenu->rgItems = NULL;
618 }
619 else
620 {
621 while (nPos < pMenu->cItems)
622 {
623 *item = *(item+1);
624 item++;
625 nPos++;
626 }
627 newItems = DesktopHeapReAlloc(pMenu->head.rpdesk, pMenu->rgItems, pMenu->cItems * sizeof(ITEM));
628 if (newItems)
629 {
630 pMenu->rgItems = newItems;
631 }
632 }
633 return TRUE;
634}
static ATOM item
Definition: dde.c:856
Definition: fontsub.cpp:36
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215
static __inline PVOID DesktopHeapReAlloc(IN PDESKTOP Desktop, IN PVOID lpMem, IN SIZE_T Bytes)
Definition: desktop.h:226
#define FreeMenuText(Menu, MenuItem)
Definition: menu.c:185
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

Referenced by IntInsertMenuItem(), MENU_GetSystemMenu(), NtUserDeleteMenu(), and NtUserRemoveMenu().

◆ IntSetMenu()

BOOL FASTCALL IntSetMenu ( PWND  Wnd,
HMENU  Menu,
BOOL Changed 
)

Definition at line 5459 of file menu.c.

5463{
5464 PMENU OldMenu, NewMenu = NULL;
5465
5466 if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
5467 {
5468 ERR("SetMenu: Window is a Child 0x%p!\n",UserHMGetHandle(Wnd));
5470 return FALSE;
5471 }
5472
5473 *Changed = (UlongToHandle(Wnd->IDMenu) != Menu);
5474 if (! *Changed)
5475 {
5476 return TRUE;
5477 }
5478
5479 if (Wnd->IDMenu)
5480 {
5481 OldMenu = IntGetMenuObject(UlongToHandle(Wnd->IDMenu));
5482 ASSERT(NULL == OldMenu || OldMenu->hWnd == UserHMGetHandle(Wnd));
5483 }
5484 else
5485 {
5486 OldMenu = NULL;
5487 }
5488
5489 if (NULL != Menu)
5490 {
5491 NewMenu = IntGetMenuObject(Menu);
5492 if (NULL == NewMenu)
5493 {
5494 if (NULL != OldMenu)
5495 {
5496 IntReleaseMenuObject(OldMenu);
5497 }
5499 return FALSE;
5500 }
5501 if (NULL != NewMenu->hWnd)
5502 {
5503 /* Can't use the same menu for two windows */
5504 if (NULL != OldMenu)
5505 {
5506 IntReleaseMenuObject(OldMenu);
5507 }
5509 return FALSE;
5510 }
5511
5512 }
5513
5514 Wnd->IDMenu = (UINT_PTR) Menu;
5515 if (NULL != NewMenu)
5516 {
5517 NewMenu->hWnd = UserHMGetHandle(Wnd);
5518 IntReleaseMenuObject(NewMenu);
5519 }
5520 if (NULL != OldMenu)
5521 {
5522 OldMenu->hWnd = NULL;
5523 IntReleaseMenuObject(OldMenu);
5524 }
5525
5526 return TRUE;
5527}
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define IntReleaseMenuObject(MenuObj)
Definition: menu.h:130
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WS_CHILD
Definition: pedump.c:617
#define WS_POPUP
Definition: pedump.c:616
DWORD style
Definition: ntuser.h:701
UINT_PTR IDMenu
Definition: ntuser.h:726
PMENU FASTCALL IntGetMenuObject(HMENU hMenu)
Definition: menu.c:194
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881

Referenced by IntCreateWindow(), and NtUserSetMenu().

◆ IntSetMenuItemInfo()

BOOL FASTCALL IntSetMenuItemInfo ( PMENU  MenuObject,
PITEM  MenuItem,
PROSMENUITEMINFO  lpmii,
PUNICODE_STRING  lpstr 
)

Definition at line 1035 of file menu.c.

1036{
1037 PMENU SubMenuObject;
1038 BOOL circref = FALSE;
1039
1040 if(!MenuItem || !MenuObject || !lpmii)
1041 {
1042 return FALSE;
1043 }
1044 if ( lpmii->fMask & MIIM_FTYPE )
1045 {
1046 MenuItem->fType &= ~MENUITEMINFO_TYPE_MASK;
1047 MenuItem->fType |= lpmii->fType & MENUITEMINFO_TYPE_MASK;
1048 }
1049 if (lpmii->fMask & MIIM_TYPE)
1050 {
1051 #if 0
1052 if (lpmii->fMask & ( MIIM_STRING | MIIM_FTYPE | MIIM_BITMAP))
1053 {
1054 ERR("IntSetMenuItemInfo: Invalid combination of fMask bits used\n");
1056 /* This does not happen on Win9x/ME */
1058 return FALSE;
1059 }
1060 #endif
1061 /*
1062 * Delete the menu item type when changing type from
1063 * MF_STRING.
1064 */
1065 if (MenuItem->fType != lpmii->fType &&
1066 MENU_ITEM_TYPE(MenuItem->fType) == MFT_STRING)
1067 {
1068 FreeMenuText(MenuObject,MenuItem);
1069 RtlInitUnicodeString(&MenuItem->lpstr, NULL);
1070 MenuItem->Xlpstr = NULL;
1071 }
1072 if(lpmii->fType & MFT_BITMAP)
1073 {
1074 if(lpmii->hbmpItem)
1075 MenuItem->hbmp = lpmii->hbmpItem;
1076 else
1077 { /* Win 9x/Me stuff */
1078 MenuItem->hbmp = (HBITMAP)((ULONG_PTR)(LOWORD(lpmii->dwTypeData)));
1079 }
1080 lpmii->dwTypeData = 0;
1081 }
1082 }
1083 if(lpmii->fMask & MIIM_BITMAP)
1084 {
1085 MenuItem->hbmp = lpmii->hbmpItem;
1086 if (MenuItem->hbmp <= HBMMENU_POPUP_MINIMIZE && MenuItem->hbmp >= HBMMENU_CALLBACK)
1087 MenuItem->fState |= MFS_HBMMENUBMP;
1088 else
1089 MenuItem->fState &= ~MFS_HBMMENUBMP;
1090 }
1091 if(lpmii->fMask & MIIM_CHECKMARKS)
1092 {
1093 MenuItem->hbmpChecked = lpmii->hbmpChecked;
1094 MenuItem->hbmpUnchecked = lpmii->hbmpUnchecked;
1095 }
1096 if(lpmii->fMask & MIIM_DATA)
1097 {
1098 MenuItem->dwItemData = lpmii->dwItemData;
1099 }
1100 if(lpmii->fMask & MIIM_ID)
1101 {
1102 MenuItem->wID = lpmii->wID;
1103 }
1104 if(lpmii->fMask & MIIM_STATE)
1105 {
1106 /* Remove MFS_DEFAULT flag from all other menu items if this item
1107 has the MFS_DEFAULT state */
1108 if(lpmii->fState & MFS_DEFAULT)
1109 UserSetMenuDefaultItem(MenuObject, -1, 0);
1110 /* Update the menu item state flags */
1111 UpdateMenuItemState(MenuItem->fState, lpmii->fState);
1112 }
1113
1114 if(lpmii->fMask & MIIM_SUBMENU)
1115 {
1116 if (lpmii->hSubMenu)
1117 {
1118 SubMenuObject = UserGetMenuObject(lpmii->hSubMenu);
1119 if ( SubMenuObject && !(UserObjectInDestroy(lpmii->hSubMenu)) )
1120 {
1123 if (MenuObject == SubMenuObject)
1124 {
1125 HANDLE hMenu;
1126 ERR("Pop Up Menu Double Trouble!\n");
1127 SubMenuObject = IntCreateMenu(&hMenu,
1128 FALSE,
1129 MenuObject->head.rpdesk,
1130 (PPROCESSINFO)MenuObject->head.hTaskWow); // It will be marked.
1131 if (!SubMenuObject) return FALSE;
1132 IntReleaseMenuObject(SubMenuObject); // This will be referenced again after insertion.
1133 circref = TRUE;
1134 }
1135 if ( MENU_depth( SubMenuObject, 0) > MAXMENUDEPTH )
1136 {
1137 ERR( "Loop detected in menu hierarchy or maximum menu depth exceeded!\n");
1138 if (circref) IntDestroyMenuObject(SubMenuObject, FALSE);
1139 return FALSE;
1140 }
1141 /* Make sure the submenu is marked as a popup menu */
1142 SubMenuObject->fFlags |= MNF_POPUP;
1143 // Now fix the test_subpopup_locked_by_menu tests....
1144 if (MenuItem->spSubMenu) IntReleaseMenuObject(MenuItem->spSubMenu);
1145 MenuItem->spSubMenu = SubMenuObject;
1146 UserReferenceObject(SubMenuObject);
1147 }
1148 else
1149 {
1151 return FALSE;
1152 }
1153 }
1154 else
1155 { // If submenu just dereference it.
1156 if (MenuItem->spSubMenu) IntReleaseMenuObject(MenuItem->spSubMenu);
1157 MenuItem->spSubMenu = NULL;
1158 }
1159 }
1160
1161 if ((lpmii->fMask & MIIM_STRING) ||
1162 ((lpmii->fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(lpmii->fType) == MF_STRING)))
1163 {
1164 /* free the string when used */
1165 FreeMenuText(MenuObject,MenuItem);
1166 RtlInitUnicodeString(&MenuItem->lpstr, NULL);
1167 MenuItem->Xlpstr = NULL;
1168
1169 if(lpmii->dwTypeData && lpmii->cch && lpstr && lpstr->Buffer)
1170 {
1172
1173 if (!NT_VERIFY(lpmii->cch <= UNICODE_STRING_MAX_CHARS))
1174 {
1175 return FALSE;
1176 }
1177
1178 Source.Length = Source.MaximumLength = (USHORT)(lpmii->cch * sizeof(WCHAR));
1179 Source.Buffer = lpmii->dwTypeData;
1180
1181 MenuItem->lpstr.Buffer = DesktopHeapAlloc( MenuObject->head.rpdesk, Source.Length + sizeof(WCHAR));
1182 if(MenuItem->lpstr.Buffer != NULL)
1183 {
1184 MenuItem->lpstr.Length = 0;
1185 MenuItem->lpstr.MaximumLength = Source.Length + sizeof(WCHAR);
1186 RtlCopyUnicodeString(&MenuItem->lpstr, &Source);
1187 MenuItem->lpstr.Buffer[MenuItem->lpstr.Length / sizeof(WCHAR)] = 0;
1188
1189 MenuItem->cch = MenuItem->lpstr.Length / sizeof(WCHAR);
1190 MenuItem->Xlpstr = (USHORT*)MenuItem->lpstr.Buffer;
1191 }
1192 }
1193 }
1194
1195 if( !(MenuObject->fFlags & MNF_SYSMENU) &&
1196 !MenuItem->Xlpstr &&
1197 !lpmii->dwTypeData &&
1198 !(MenuItem->fType & MFT_OWNERDRAW) &&
1199 !MenuItem->hbmp)
1200 MenuItem->fType |= MFT_SEPARATOR;
1201
1202 if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
1203 {
1204 MenuItem->xItem = lpmii->Rect.left;
1205 MenuItem->yItem = lpmii->Rect.top;
1206 MenuItem->cxItem = lpmii->Rect.right; // Do this for now......
1207 MenuItem->cyItem = lpmii->Rect.bottom;
1208 MenuItem->dxTab = lpmii->dxTab;
1209 lpmii->lpstr = MenuItem->lpstr.Buffer; /* Send back new allocated string or zero */
1210 MenuItem->cxBmp = lpmii->maxBmpSize.cx;
1211 MenuItem->cyBmp = lpmii->maxBmpSize.cy;
1212 }
1213
1214 return TRUE;
1215}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define MNF_SYSMENU
Definition: ntuser.h:405
#define MFS_HBMMENUBMP
Definition: ntuser.h:363
#define MENU_ITEM_TYPE(flags)
Definition: menu.h:6
static HBITMAP
Definition: button.c:44
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_STRING_MAX_CHARS
#define LOWORD(l)
Definition: pedump.c:82
unsigned short USHORT
Definition: pedump.c:61
struct _DESKTOP * rpdesk
Definition: ntuser.h:219
DWORD_PTR hTaskWow
Definition: ntuser.h:218
USHORT MaximumLength
Definition: env_spec_w32.h:370
HBITMAP hbmp
Definition: ntuser.h:383
INT cyBmp
Definition: ntuser.h:385
ULONG yItem
Definition: ntuser.h:377
DWORD_PTR dwItemData
Definition: ntuser.h:375
UINT wID
Definition: ntuser.h:369
ULONG dxTab
Definition: ntuser.h:380
UNICODE_STRING lpstr
Definition: ntuser.h:387
USHORT * Xlpstr
Definition: ntuser.h:373
ULONG xItem
Definition: ntuser.h:376
INT cxBmp
Definition: ntuser.h:384
ULONG cxItem
Definition: ntuser.h:378
ULONG cyItem
Definition: ntuser.h:379
ULONG cch
Definition: ntuser.h:374
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HBITMAP hbmpItem
Definition: menu.h:114
HBITMAP hbmpUnchecked
Definition: menu.h:110
SIZE maxBmpSize
Definition: menu.h:119
HMENU hSubMenu
Definition: menu.h:108
LPWSTR dwTypeData
Definition: menu.h:112
LPWSTR lpstr
Definition: menu.h:118
HBITMAP hbmpChecked
Definition: menu.h:109
DWORD dwItemData
Definition: menu.h:111
LONG cx
Definition: windef.h:334
LONG cy
Definition: windef.h:335
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
#define MAXMENUDEPTH
Definition: menu.c:43
BOOL FASTCALL UserSetMenuDefaultItem(PMENU MenuObject, UINT uItem, UINT fByPos)
Definition: menu.c:1276
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:47
#define UpdateMenuItemState(state, change)
Definition: menu.c:97
PMENU FASTCALL IntCreateMenu(_Out_ PHANDLE Handle, _In_ BOOL IsMenuBar, _In_ PDESKTOP Desktop, _In_ PPROCESSINFO ppi)
Definition: menu.c:731
int FASTCALL MENU_depth(PMENU pmenu, int depth)
Definition: menu.c:406
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:703
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
#define MIIM_STRING
Definition: winuser.h:722
#define MIIM_ID
Definition: winuser.h:717
#define HBMMENU_POPUP_MINIMIZE
Definition: winuser.h:2630
#define MIIM_CHECKMARKS
Definition: winuser.h:719
#define MF_STRING
Definition: winuser.h:138
#define MIIM_FTYPE
Definition: winuser.h:724
#define MFT_SEPARATOR
Definition: winuser.h:739
#define MIIM_STATE
Definition: winuser.h:716
#define MFS_DEFAULT
Definition: winuser.h:743
#define MFT_OWNERDRAW
Definition: winuser.h:736
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MIIM_BITMAP
Definition: winuser.h:723
#define MFT_BITMAP
Definition: winuser.h:733
#define MFT_STRING
Definition: winuser.h:741
#define HBMMENU_CALLBACK
Definition: winuser.h:2620
#define MIIM_DATA
Definition: winuser.h:721
#define MIIM_TYPE
Definition: winuser.h:720
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3287
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IntInsertMenuItem(), IntMenuItemInfo(), and UserMenuItemInfo().

◆ IntTrackPopupMenuEx()

BOOL WINAPI IntTrackPopupMenuEx ( PMENU  menu,
UINT  wFlags,
int  x,
int  y,
PWND  pWnd,
LPTPMPARAMS  lpTpm 
)

Definition at line 4561 of file menu.c.

4563{
4564 BOOL ret = FALSE;
4566
4567 if (pti != pWnd->head.pti)
4568 {
4569 ERR("Must be the same pti!\n");
4570 return ret;
4571 }
4572
4573 TRACE("hmenu %p flags %04x (%d,%d) hwnd %p lpTpm %p \n", //rect %s\n",
4574 UserHMGetHandle(menu), wFlags, x, y, UserHMGetHandle(pWnd), lpTpm); //,
4575 //lpTpm ? wine_dbgstr_rect( &lpTpm->rcExclude) : "-" );
4576
4577 if (menu->hWnd && IntIsWindow(menu->hWnd))
4578 {
4580 return FALSE;
4581 }
4582
4583 if (MENU_InitPopup( pWnd, menu, wFlags ))
4584 {
4585 MENU_InitTracking(pWnd, menu, TRUE, wFlags);
4586
4587 /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
4588 if (!(wFlags & TPM_NONOTIFY))
4589 {
4591 }
4592
4593 if (menu->fFlags & MNF_SYSMENU)
4594 MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
4595
4596 if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y, lpTpm ? &lpTpm->rcExclude : NULL))
4597 ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd);
4598 else
4599 {
4601 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4602 co_UserSetCapture(NULL); /* release the capture */
4603 }
4604
4606
4607 if (menu->hWnd)
4608 {
4609 PWND pwndM = ValidateHwndNoErr( menu->hWnd );
4610 if (pwndM) // wine hack around this with their destroy function.
4611 {
4612 if (!(pWnd->state & WNDS_DESTROYED))
4613 co_UserDestroyWindow( pwndM ); // Fix wrong error return.
4614 }
4615 menu->hWnd = 0;
4616
4617 if (!(wFlags & TPM_NONOTIFY))
4618 {
4619 co_IntSendMessage( UserHMGetHandle(pWnd), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(menu),
4620 MAKELPARAM(0, IS_SYSTEM_MENU(menu)) );
4621 }
4622 }
4623 }
4624 return ret;
4625}
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1458
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define WNDS_DESTROYED
Definition: ntuser.h:631
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3702
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2551
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
UINT style
Definition: ntuser.h:575
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
PCLS pcls
Definition: ntuser.h:715
THRDESKHEAD head
Definition: ntuser.h:690
DWORD state
Definition: ntuser.h:696
RECT rcExclude
Definition: winuser.h:3566
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2848
#define IS_SYSTEM_MENU(MenuInfo)
Definition: menu.c:60
static BOOL MENU_InitPopup(PWND pWndOwner, PMENU menu, UINT flags)
Definition: menu.c:2783
static BOOL FASTCALL MENU_ExitTracking(PWND pWnd, BOOL bPopup, UINT wFlags)
Definition: menu.c:4448
#define TPM_POPUPMENU
Definition: menu.c:92
static BOOL FASTCALL MENU_ShowPopup(PWND pwndOwner, PMENU menu, UINT id, UINT flags, INT x, INT y, const RECT *pExclude)
Definition: menu.c:2941
void FASTCALL MENU_InitSysMenuPopup(PMENU menu, DWORD style, DWORD clsStyle, LONG HitTest)
Definition: menu.c:1364
static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
Definition: menu.c:4054
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4388
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:188
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define TPM_NONOTIFY
Definition: winuser.h:2376
#define WM_INITMENUPOPUP
Definition: winuser.h:1736
#define HTSYSMENU
Definition: winuser.h:2467

Referenced by IntDefWindowProc(), and NtUserTrackPopupMenuEx().

◆ MENU_DrawMenuBar()

UINT MENU_DrawMenuBar ( HDC  hDC,
LPRECT  lprect,
PWND  pWnd,
BOOL  suppress_draw 
)

Definition at line 2744 of file menu.c.

2745{
2746 HFONT hfontOld = 0;
2748
2749 if (lppop == NULL)
2750 {
2751 // No menu. Do not reserve any space
2752 return 0;
2753 }
2754
2755 if (lprect == NULL)
2756 {
2758 }
2759
2760 if (suppress_draw)
2761 {
2762 hfontOld = NtGdiSelectFont(hDC, ghMenuFont);
2763
2764 MENU_MenuBarCalcSize(hDC, lprect, lppop, pWnd);
2765
2766 lprect->bottom = lprect->top + lppop->cyMenu;
2767
2768 if (hfontOld) NtGdiSelectFont( hDC, hfontOld);
2769
2770 return lppop->cyMenu;
2771 }
2772 else
2773 {
2774 return IntDrawMenuBarTemp(pWnd, hDC, lprect, lppop, NULL);
2775 }
2776}
static HDC hDC
Definition: 3dtext.c:33
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
__kernel_entry W32KAPI HFONT APIENTRY NtGdiSelectFont(_In_ HDC hdc, _In_ HFONT hf)
Definition: dcobjs.c:597
DWORD WINAPI IntDrawMenuBarTemp(PWND pWnd, HDC hDC, LPRECT Rect, PMENU pMenu, HFONT Font)
Definition: menu.c:2687
HFONT ghMenuFont
Definition: menu.c:16
static void MENU_MenuBarCalcSize(HDC hdc, LPRECT lprect, PMENU lppop, PWND pwndOwner)
Definition: menu.c:2103
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:208
#define SM_CYMENU
Definition: winuser.h:970

Referenced by NC_DoNCPaint(), NC_HandleNCCalcSize(), NtUserCalcMenuBar(), NtUserPaintMenuBar(), and UserDrawCaptionBar().

◆ MENU_EndMenu()

void MENU_EndMenu ( PWND  pwnd)

Definition at line 2664 of file menu.c.

2665{
2666 PMENU menu = NULL;
2668 if ( menu && ( UserHMGetHandle(pwnd) == menu->hWnd || pwnd == menu->spwndNotify ) )
2669 {
2671 {
2673
2674 if (fInEndMenu)
2675 {
2676 ERR("Already in End loop\n");
2677 return;
2678 }
2679
2680 fInEndMenu = TRUE;
2682 }
2683 }
2684}
static HMENU top_popup_hmenu
Definition: menu.c:23
static HWND top_popup
Definition: menu.c:22
BOOL fInsideMenuLoop
Definition: menu.c:25
BOOL fInEndMenu
Definition: menu.c:26
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
#define WM_CANCELMODE
Definition: winuser.h:1625

Referenced by IntDefWindowProc().

◆ MENU_FindItem()

PITEM FASTCALL MENU_FindItem ( PMENU pmenu,
UINT nPos,
UINT  wFlags 
)

Definition at line 509 of file menu.c.

510{
511 MENU *menu = *pmenu;
512 ITEM *fallback = NULL;
513 UINT fallback_pos = 0;
514 UINT i;
515
516 if (!menu) return NULL;
517
518 if (wFlags & MF_BYPOSITION)
519 {
520 if (!menu->cItems) return NULL;
521 if (*nPos >= menu->cItems) return NULL;
522 return &menu->rgItems[*nPos];
523 }
524 else
525 {
526 PITEM item = menu->rgItems;
527 for (i = 0; i < menu->cItems; i++, item++)
528 {
529 if (item->spSubMenu)
530 {
531 PMENU psubmenu = item->spSubMenu;//VerifyMenu(item->spSubMenu);
532 PITEM subitem = MENU_FindItem( &psubmenu, nPos, wFlags );
533 if (subitem)
534 {
535 *pmenu = psubmenu;
536 return subitem;
537 }
538 else if (item->wID == *nPos)
539 {
540 /* fallback to this item if nothing else found */
541 fallback_pos = i;
542 fallback = item;
543 }
544 }
545 else if (item->wID == *nPos)
546 {
547 *nPos = i;
548 return item;
549 }
550 }
551 }
552
553 if (fallback)
554 *nPos = fallback_pos;
555
556 return fallback;
557}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by CheckMenuItem(), CheckMenuRadioItem(), co_IntGetSubMenu(), co_IntTranslateAccelerator(), GetMenuItemID(), GetMenuItemInfo_common(), GetMenuState(), GetMenuStringA(), GetMenuStringW(), GetSubMenu(), IntCheckMenuItem(), IntEnableMenuItem(), IntGetMenuItemRect(), IntGetMenuState(), IntGetSubMenu(), IntHiliteMenuItem(), IntMenuItemInfo(), IntRemoveMenuItem(), MENU_FindItem(), MENU_InsertItem(), NtUserGetMenuItemRect(), and UserMenuItemInfo().

◆ MENU_InitSysMenuPopup()

void FASTCALL MENU_InitSysMenuPopup ( PMENU  menu,
DWORD  style,
DWORD  clsStyle,
LONG  HitTest 
)

Definition at line 1364 of file menu.c.

1365{
1366 BOOL gray;
1367 UINT DefItem;
1368
1369 gray = !(style & WS_THICKFRAME) || (style & (WS_MAXIMIZE | WS_MINIMIZE));
1370 IntEnableMenuItem( menu, SC_SIZE, (gray ? MF_GRAYED : MF_ENABLED) );
1371 gray = ((style & WS_MAXIMIZE) != 0);
1372 IntEnableMenuItem( menu, SC_MOVE, (gray ? MF_GRAYED : MF_ENABLED) );
1373 gray = !(style & WS_MINIMIZEBOX) || (style & WS_MINIMIZE);
1375 gray = !(style & WS_MAXIMIZEBOX) || (style & WS_MAXIMIZE);
1377 gray = !(style & (WS_MAXIMIZE | WS_MINIMIZE));
1378 IntEnableMenuItem( menu, SC_RESTORE, (gray ? MF_GRAYED : MF_ENABLED) );
1379 gray = (clsStyle & CS_NOCLOSE) != 0;
1380
1381 /* The menu item must keep its state if it's disabled */
1382 if(gray)
1384
1385 /* Set default menu item */
1386 if(style & WS_MINIMIZE) DefItem = SC_RESTORE;
1387 else if(HitTest == HTCAPTION) DefItem = ((style & (WS_MAXIMIZE | WS_MINIMIZE)) ? SC_RESTORE : SC_MAXIMIZE);
1388 else DefItem = SC_CLOSE;
1389
1390 UserSetMenuDefaultItem(menu, DefItem, MF_BYCOMMAND);
1391}
Arabic default style
Definition: afstyles.h:94
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_MINIMIZEBOX
Definition: pedump.c:631
#define WS_THICKFRAME
Definition: pedump.c:630
UINT FASTCALL IntEnableMenuItem(PMENU MenuObject, UINT uIDEnableItem, UINT uEnable)
Definition: menu.c:1219
#define HTCAPTION
Definition: winuser.h:2466
#define SC_SIZE
Definition: winuser.h:2574
#define SC_MINIMIZE
Definition: winuser.h:2576
#define MF_ENABLED
Definition: winuser.h:128
#define SC_CLOSE
Definition: winuser.h:2582
#define SC_MOVE
Definition: winuser.h:2575
#define SC_RESTORE
Definition: winuser.h:2588
#define CS_NOCLOSE
Definition: winuser.h:649
#define SC_MAXIMIZE
Definition: winuser.h:2578
#define MF_GRAYED
Definition: winuser.h:129

Referenced by IntDefWindowProc(), IntTrackPopupMenuEx(), and MENU_ShowSubPopup().

◆ MENU_IsMenuActive()

PWND MENU_IsMenuActive ( VOID  )

Definition at line 2652 of file menu.c.

2653{
2655}

Referenced by IntDefWindowProc().

◆ MENU_TrackKbdMenuBar()

VOID MENU_TrackKbdMenuBar ( PWND  pwnd,
UINT  wParam,
WCHAR  wChar 
)

Definition at line 4500 of file menu.c.

4501{
4502 UINT uItem = NO_SELECTED_ITEM;
4503 PMENU TrackMenu;
4505
4506 TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", UserHMGetHandle(pwnd), wParam, wChar);
4507
4508 /* find window that has a menu */
4509
4510 while (!( (pwnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD ) )
4511 if (!(pwnd = UserGetAncestor( pwnd, GA_PARENT ))) return;
4512
4513 /* check if we have to track a system menu */
4514
4515 TrackMenu = IntGetMenu( UserHMGetHandle(pwnd) );
4516 if (!TrackMenu || (pwnd->style & WS_MINIMIZE) != 0 || wChar == ' ' )
4517 {
4518 if (!(pwnd->style & WS_SYSMENU)) return;
4519 TrackMenu = get_win_sys_menu( UserHMGetHandle(pwnd) );
4520 uItem = 0;
4521 wParam |= HTSYSMENU; /* prevent item lookup */
4522 }
4523
4524 if (!VerifyMenu( TrackMenu )) return;
4525
4526 MENU_InitTracking( pwnd, TrackMenu, FALSE, wFlags );
4527
4528 /* fetch the window menu again, it may have changed */
4529 TrackMenu = (wParam & HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pwnd) ) : IntGetMenu( UserHMGetHandle(pwnd) );
4530
4531 if( wChar && wChar != ' ' )
4532 {
4533 uItem = MENU_FindItemByKey( pwnd, TrackMenu, wChar, (wParam & HTSYSMENU) );
4534 if ( uItem >= (UINT)(-2) )
4535 {
4536 if( uItem == (UINT)(-1) ) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0);
4537 /* schedule end of menu tracking */
4538 wFlags |= TF_ENDMENU;
4539 goto track_menu;
4540 }
4541 }
4542
4543 MENU_SelectItem( pwnd, TrackMenu, uItem, TRUE, 0 );
4544
4545 if (!(wParam & HTSYSMENU) || wChar == ' ')
4546 {
4547 if( uItem == NO_SELECTED_ITEM )
4548 MENU_MoveSelection( pwnd, TrackMenu, ITEM_NEXT );
4549 else
4551 }
4552
4553track_menu:
4554 MENU_TrackMenu( TrackMenu, wFlags, 0, 0, pwnd );
4556}
WPARAM wParam
Definition: combotst.c:138
HWND hwndSAS
Definition: winsta.c:24
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
#define LN_MESSAGE_BEEP
Definition: undocuser.h:120
PWND FASTCALL UserGetAncestor(PWND Wnd, UINT Type)
Definition: window.c:3335
#define TF_ENDMENU
Definition: menu.c:35
PMENU get_win_sys_menu(HWND hwnd)
Definition: menu.c:260
PMENU FASTCALL VerifyMenu(PMENU pMenu)
Definition: menu.c:203
static void FASTCALL MENU_MoveSelection(PWND pwndOwner, PMENU menu, INT offset)
Definition: menu.c:3228
static UINT FASTCALL MENU_FindItemByKey(PWND WndOwner, PMENU menu, WCHAR Key, BOOL ForceMenuChar)
Definition: menu.c:1537
static void FASTCALL MENU_SelectItem(PWND pwndOwner, PMENU menu, UINT wIndex, BOOL sendMenuSelect, PMENU topmenu)
Definition: menu.c:3141
PMENU WINAPI IntGetMenu(HWND hWnd)
Definition: menu.c:250
#define ITEM_NEXT
Definition: menu.c:95
#define GA_PARENT
Definition: winuser.h:2778
#define VK_RETURN
Definition: winuser.h:2191
#define TPM_LEFTALIGN
Definition: winuser.h:2367
#define TPM_LEFTBUTTON
Definition: winuser.h:2369
#define WM_KEYDOWN
Definition: winuser.h:1705

Referenced by DefWndHandleSysCommand().

◆ MENU_TrackMouseMenuBar()

VOID MENU_TrackMouseMenuBar ( PWND  pWnd,
ULONG  ht,
POINT  pt 
)

Definition at line 4470 of file menu.c.

4471{
4472 PMENU pMenu = (ht == HTSYSMENU) ? IntGetSystemMenu(pWnd, FALSE) : IntGetMenu( UserHMGetHandle(pWnd) ); // See 74276 and CORE-12801
4474
4475 TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", pWnd, ht, pt.x, pt.y);
4476
4477 if (pWnd->ExStyle & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
4478 if (VerifyMenu(pMenu))
4479 {
4480 /* map point to parent client coordinates */
4483 {
4485 }
4486
4487 MENU_InitTracking(pWnd, pMenu, FALSE, wFlags);
4488 /* fetch the window menu again, it may have changed */
4489 pMenu = (ht == HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pWnd) ) : IntGetMenu( UserHMGetHandle(pWnd) );
4490 MENU_TrackMenu(pMenu, wFlags, pt.x, pt.y, pWnd);
4492 }
4493}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
#define pt(x, y)
Definition: drawing.c:79
static const struct newhuff ht[]
Definition: huffman.h:296
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:212
DWORD ExStyle
Definition: ntuser.h:699
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
PMENU FASTCALL IntGetSystemMenu(PWND Window, BOOL bRevert)
Definition: menu.c:5383
#define TPM_BUTTONDOWN
Definition: menu.c:91
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define TPM_VERTICAL
Definition: winuser.h:2372

Referenced by DefWndHandleSysCommand().

◆ MenuInit()

BOOL MenuInit ( VOID  )

Definition at line 361 of file menu.c.

362{
363 NONCLIENTMETRICSW ncm;
364
365 /* get the menu font */
366 if (!ghMenuFont || !ghMenuFontBold)
367 {
368 ncm.cbSize = sizeof(ncm);
369 if(!UserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0))
370 {
371 ERR("MenuInit(): SystemParametersInfo(SPI_GETNONCLIENTMETRICS) failed!\n");
372 return FALSE;
373 }
374
375 ghMenuFont = GreCreateFontIndirectW(&ncm.lfMenuFont);
376 if (ghMenuFont == NULL)
377 {
378 ERR("MenuInit(): CreateFontIndirectW(hMenuFont) failed!\n");
379 return FALSE;
380 }
381 ncm.lfMenuFont.lfWeight = min(ncm.lfMenuFont.lfWeight + (FW_BOLD - FW_NORMAL), FW_HEAVY);
382 ghMenuFontBold = GreCreateFontIndirectW(&ncm.lfMenuFont);
383 if (ghMenuFontBold == NULL)
384 {
385 ERR("MenuInit(): CreateFontIndirectW(hMenuFontBold) failed!\n");
388 return FALSE;
389 }
390
393
395 }
396
397 return TRUE;
398}
#define min(a, b)
Definition: monoChain.cc:55
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
HFONT FASTCALL GreCreateFontIndirectW(LOGFONTW *lplf)
Definition: font.c:23
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1255
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
VOID FASTCALL co_IntSetupOBM(VOID)
Definition: callback.c:1180
HFONT ghMenuFontBold
Definition: menu.c:17
BOOL FASTCALL UserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2104
#define FW_BOLD
Definition: wingdi.h:378
#define FW_NORMAL
Definition: wingdi.h:373
#define FW_HEAVY
Definition: wingdi.h:381

◆ PopupMenuWndProc()

BOOL WINAPI PopupMenuWndProc ( PWND  Wnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam,
LRESULT lResult 
)

Definition at line 4631 of file menu.c.

4637{
4638 PPOPUPMENU pPopupMenu;
4639
4640 *lResult = 0;
4641
4642 TRACE("PMWP : pwnd=%x msg=%d wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
4643
4644 if (Wnd)
4645 {
4646 if (!Wnd->fnid)
4647 {
4648 if (Message != WM_NCCREATE)
4649 {
4650 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4651 return TRUE;
4652 }
4653 Wnd->fnid = FNID_MENU;
4654 pPopupMenu = DesktopHeapAlloc( Wnd->head.rpdesk, sizeof(POPUPMENU) );
4655 if (pPopupMenu == NULL)
4656 {
4657 return TRUE;
4658 }
4659 pPopupMenu->posSelectedItem = NO_SELECTED_ITEM;
4660 pPopupMenu->spwndPopupMenu = Wnd;
4661 ((PMENUWND)Wnd)->ppopupmenu = pPopupMenu;
4662 TRACE("Pop Up Menu is Setup! Msg %d\n",Message);
4663 *lResult = 1;
4664 return TRUE;
4665 }
4666 else
4667 {
4668 if (Wnd->fnid != FNID_MENU)
4669 {
4670 ERR("Wrong window class for Menu! fnid %x\n",Wnd->fnid);
4671 return TRUE;
4672 }
4673 pPopupMenu = ((PMENUWND)Wnd)->ppopupmenu;
4674 }
4675 }
4676
4677 switch(Message)
4678 {
4679 case WM_CREATE:
4680 {
4682 pPopupMenu->spmenu = UserGetMenuObject(cs->lpCreateParams);
4683 if (pPopupMenu->spmenu)
4684 {
4685 UserReferenceObject(pPopupMenu->spmenu);
4686 }
4687 break;
4688 }
4689
4690 case WM_MOUSEACTIVATE: /* We don't want to be activated */
4691 *lResult = MA_NOACTIVATE;
4692 break;
4693
4694 case WM_PAINT:
4695 {
4696 PAINTSTRUCT ps;
4697 IntBeginPaint(Wnd, &ps);
4698 MENU_DrawPopupMenu(Wnd, ps.hdc, pPopupMenu->spmenu);
4699 IntEndPaint(Wnd, &ps);
4700 break;
4701 }
4702
4703 case WM_PRINTCLIENT:
4704 {
4705 MENU_DrawPopupMenu( Wnd, (HDC)wParam, pPopupMenu->spmenu);
4706 break;
4707 }
4708
4709 case WM_ERASEBKGND:
4710 *lResult = 1;
4711 break;
4712
4713 case WM_DESTROY:
4714 /* zero out global pointer in case resident popup window was destroyed. */
4715 if (pPopupMenu)
4716 {
4717 if (UserHMGetHandle(Wnd) == top_popup)
4718 {
4719 top_popup = NULL;
4721 }
4722 }
4723 else
4724 {
4725 ERR("No Window Pop Up!\n");
4726 }
4727 break;
4728
4729 case WM_NCDESTROY:
4730 {
4731 if (pPopupMenu->spmenu)
4732 {
4733 IntReleaseMenuObject(pPopupMenu->spmenu);
4734 }
4735 DesktopHeapFree(Wnd->head.rpdesk, pPopupMenu );
4736 ((PMENUWND)Wnd)->ppopupmenu = 0;
4737 Wnd->fnid = FNID_DESTROY;
4738 break;
4739 }
4740
4741 case MM_SETMENUHANDLE: // wine'isms
4742 case MN_SETHMENU:
4743 {
4745 if (!pmenu)
4746 {
4747 ERR("Bad Menu Handle\n");
4748 break;
4749 }
4750 UserReferenceObject(pmenu);
4751 if (pPopupMenu->spmenu)
4752 {
4753 IntReleaseMenuObject(pPopupMenu->spmenu);
4754 }
4755 pPopupMenu->spmenu = pmenu;
4756 break;
4757 }
4758
4759 case MM_GETMENUHANDLE: // wine'isms
4760 case MN_GETHMENU:
4761 *lResult = (LRESULT)(pPopupMenu ? (pPopupMenu->spmenu ? UserHMGetHandle(pPopupMenu->spmenu) : NULL) : NULL);
4762 break;
4763
4764 default:
4765 if (Message > MN_GETHMENU && Message < MN_GETHMENU+19)
4766 {
4767 ERR("Someone is passing unknown menu messages %d\n",Message);
4768 }
4769 TRACE("PMWP to IDWP %d\n",Message);
4770 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4771 break;
4772 }
4773
4774 return TRUE;
4775}
LPARAM lParam
Definition: combotst.c:139
static const WCHAR Message[]
Definition: register.c:74
#define cs
Definition: i386-dis.c:443
struct _MENUWND * PMENUWND
#define FNID_DESTROY
Definition: ntuser.h:893
#define FNID_MENU
Definition: ntuser.h:856
static HDC
Definition: imagelist.c:92
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:537
#define LRESULT
Definition: ole.h:14
#define WM_PRINTCLIENT
Definition: richedit.h:70
struct _DESKTOP * rpdesk
Definition: ntuser.h:194
DWORD fnid
Definition: ntuser.h:704
PMENU spmenu
Definition: ntuser.h:468
UINT posSelectedItem
Definition: ntuser.h:473
struct _WND * spwndPopupMenu
Definition: ntuser.h:465
#define MN_SETHMENU
Definition: undocuser.h:53
HDC FASTCALL IntBeginPaint(PWND Window, PPAINTSTRUCT Ps)
Definition: painting.c:1435
BOOL FASTCALL IntEndPaint(PWND Wnd, PPAINTSTRUCT Ps)
Definition: painting.c:1532
static void FASTCALL MENU_DrawPopupMenu(PWND wnd, HDC hdc, PMENU menu)
Definition: menu.c:2601
#define MM_SETMENUHANDLE
Definition: menu.c:30
#define MM_GETMENUHANDLE
Definition: menu.c:31
#define WM_PAINT
Definition: winuser.h:1610
#define WM_ERASEBKGND
Definition: winuser.h:1615
#define WM_CREATE
Definition: winuser.h:1598
#define MN_GETHMENU
Definition: winuser.h:1763
#define MA_NOACTIVATE
Definition: winuser.h:2493
#define WM_NCCREATE
Definition: winuser.h:1673
#define WM_MOUSEACTIVATE
Definition: winuser.h:1627
#define WM_NCDESTROY
Definition: winuser.h:1674
#define WM_DESTROY
Definition: winuser.h:1599

Referenced by co_IntSendMessageTimeoutSingle(), co_IntSendMessageWithCallBack(), IntDispatchMessage(), and NtUserMessageCall().

◆ UserDestroyMenuObject()

BOOLEAN UserDestroyMenuObject ( PVOID  Object)

Definition at line 313 of file menu.c.

314{
316}
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object