ReactOS 0.4.15-dev-7889-g76290a6
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 822 of file menu.c.

823{
824 HANDLE hMenu;
825 PMENU Menu;
826
827 if(!Source)
828 return NULL;
829
830 /* A menu is valid process wide. We can pass to the object manager any thread ptr */
832 Source->head.rpdesk,
833 ((PPROCESSINFO)Source->head.hTaskWow)->ptiList,
834 &hMenu,
835 TYPE_MENU,
836 sizeof(MENU));
837 if(!Menu)
838 return NULL;
839
840 Menu->fFlags = Source->fFlags;
841 Menu->cyMax = Source->cyMax;
842 Menu->hbrBack = Source->hbrBack;
843 Menu->dwContextHelpId = Source->dwContextHelpId;
844 Menu->dwMenuData = Source->dwMenuData;
845 Menu->iItem = NO_SELECTED_ITEM;
846 Menu->spwndNotify = NULL;
847 Menu->cyMenu = 0;
848 Menu->cxMenu = 0;
849 Menu->cItems = 0;
850 Menu->iTop = 0;
851 Menu->iMaxTop = 0;
852 Menu->cxTextAlign = 0;
853 Menu->rgItems = NULL;
854
855 Menu->hWnd = NULL;
856 Menu->TimeToHide = FALSE;
857
859
860 return Menu;
861}
#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:413
struct tagMENU * PMENU
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
ULONG fFlags
Definition: ntuser.h:418
ULONG cyMenu
Definition: ntuser.h:423
struct _WND * spwndNotify
Definition: ntuser.h:425
INT iItem
Definition: ntuser.h:419
UINT cItems
Definition: ntuser.h:421
DWORD dwContextHelpId
Definition: ntuser.h:428
BOOL TimeToHide
Definition: ntuser.h:438
DWORD_PTR dwMenuData
Definition: ntuser.h:430
HWND hWnd
Definition: ntuser.h:437
ULONG cxMenu
Definition: ntuser.h:422
ULONG cyMax
Definition: ntuser.h:429
INT iTop
Definition: ntuser.h:432
INT iMaxTop
Definition: ntuser.h:433
HBRUSH hbrBack
Definition: ntuser.h:431
ULONG cxTextAlign
Definition: ntuser.h:424
PITEM rgItems
Definition: ntuser.h:426
BOOL FASTCALL IntCloneMenuItems(PMENU Destination, PMENU Source)
Definition: menu.c:771
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 317 of file menu.c.

318{
320 if (Menu)
321 {
322 PWND Window;
323
324 if (PsGetCurrentProcessSessionId() == Menu->head.rpdesk->rpwinstaParent->dwSessionId)
325 {
326 BOOL ret;
327 if (Menu->hWnd)
328 {
329 Window = ValidateHwndNoErr(Menu->hWnd);
330 if (Window)
331 {
332 //Window->IDMenu = 0; Only in Win9x!! wine win test_SetMenu test...
333
334 /* DestroyMenu should not destroy system menu popup owner */
335 if ((Menu->fFlags & (MNF_POPUP | MNF_SYSSUBMENU)) == MNF_POPUP)
336 {
337 // Should we check it to see if it has Class?
338 ERR("FIXME Pop up menu window thing'ie\n");
339 //co_UserDestroyWindow( Window );
340 //Menu->hWnd = 0;
341 }
342 }
343 }
344
345 if (!UserMarkObjectDestroy(Menu)) return TRUE;
346
347 /* Remove all menu items */
348 IntDestroyMenu( Menu, bRecurse);
349
351 TRACE("IntDestroyMenuObject %d\n",ret);
352 return ret;
353 }
354 }
355 return FALSE;
356}
#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:408
#define MNF_POPUP
Definition: ntuser.h:402
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define ASSERT(a)
Definition: mode.c:44
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:224
#define TRACE(s)
Definition: solgame.cpp:4
Definition: window.c:28
Definition: ntuser.h:694
int ret
BOOL IntDestroyMenu(PMENU pMenu, BOOL bRecurse)
Definition: menu.c:269
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 5003 of file menu.c.

5004{
5005 PMENU menu, pSubTarget;
5006 UINT Pos;
5007 if (((*hMenu)==(HMENU)0xffff) ||(!(menu = UserGetMenuObject(*hMenu))))
5008 return NO_SELECTED_ITEM;
5009
5010 pSubTarget = UserGetMenuObject(hSubTarget);
5011
5012 Pos = MENU_FindSubMenu(&menu, pSubTarget );
5013
5014 *hMenu = (menu ? UserHMGetHandle(menu) : NULL);
5015
5016 return Pos;
5017}
ush Pos
Definition: deflate.h:92
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
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:564

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 192 of file menu.c.

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

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

◆ IntGetMenuState()

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

Definition at line 4963 of file menu.c.

4964{
4965 PMENU MenuObject;
4966 PITEM pItem;
4967
4968 if (!(MenuObject = UserGetMenuObject(hMenu)))
4969 {
4970 return (UINT)-1;
4971 }
4972
4973 if (!(pItem = MENU_FindItem( &MenuObject, &uId, uFlags ))) return -1;
4974
4975 if (pItem->spSubMenu)
4976 {
4977 return (pItem->spSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|MF_POPUP) & 0xff);
4978 }
4979 else
4980 return (pItem->fType | pItem->fState);
4981}
UINT uFlags
Definition: api.c:59
UINT fType
Definition: ntuser.h:372
UINT fState
Definition: ntuser.h:373
struct tagMENU * spSubMenu
Definition: ntuser.h:375
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
#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 5371 of file menu.c.

5372{
5373 PMENU Menu;
5374
5375 if (bRevert)
5376 {
5377 if (Window->SystemMenu)
5378 {
5379 Menu = UserGetMenuObject(Window->SystemMenu);
5380 if (Menu && !(Menu->fFlags & MNF_SYSDESKMN))
5381 {
5383 Window->SystemMenu = NULL;
5384 }
5385 }
5386 }
5387 else
5388 {
5389 Menu = Window->SystemMenu ? UserGetMenuObject(Window->SystemMenu) : NULL;
5390 if ((!Menu || Menu->fFlags & MNF_SYSDESKMN) && Window->style & WS_SYSMENU)
5391 {
5393 Window->SystemMenu = Menu ? UserHMGetHandle(Menu) : NULL;
5394 }
5395 }
5396
5397 if (Window->SystemMenu)
5398 {
5399 HMENU hMenu = IntGetSubMenu( Window->SystemMenu, 0);
5400 /* Store the dummy sysmenu handle to facilitate the refresh */
5401 /* of the close button if the SC_CLOSE item change */
5402 Menu = UserGetMenuObject(hMenu);
5403 if (Menu)
5404 {
5405 Menu->spwndNotify = Window;
5406 Menu->fFlags |= MNF_SYSSUBMENU;
5407 }
5408 return Menu;
5409 }
5410 return NULL;
5411}
#define MNF_SYSDESKMN
Definition: ntuser.h:407
#define WS_SYSMENU
Definition: pedump.c:629
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
PMENU FASTCALL MENU_GetSystemMenu(PWND Window, PMENU Popup)
Definition: menu.c:5266
HMENU FASTCALL IntGetSubMenu(HMENU hMenu, int nPos)
Definition: menu.c:4983

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 691 of file menu.c.

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

241{
242 if (UserGetMenuObject(Menu)) return TRUE;
243 return FALSE;
244}

◆ IntMenuItemFromPoint()

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

Definition at line 1518 of file menu.c.

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

Referenced by IntDefWindowProc().

◆ IntMenuItemInfo()

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

Definition at line 5064 of file menu.c.

5071{
5072 PITEM MenuItem;
5073 BOOL Ret;
5074
5075 if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5076 {
5078 return FALSE;
5079 }
5080 if (SetOrGet)
5081 {
5082 Ret = IntSetMenuItemInfo(Menu, MenuItem, ItemInfo, lpstr);
5083 }
5084 else
5085 {
5086 Ret = IntGetMenuItemInfo(Menu, MenuItem, ItemInfo);
5087 }
5088 return Ret;
5089}
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
BOOL FASTCALL IntGetMenuItemInfo(PMENU Menu, PITEM MenuItem, PROSMENUITEMINFO lpmii)
Definition: menu.c:962
#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 596 of file menu.c.

597{
598 PITEM item;
599 PITEM newItems;
600
601 TRACE("(menu=%p pos=%04x flags=%04x)\n",pMenu, nPos, wFlags);
602 if (!(item = MENU_FindItem( &pMenu, &nPos, wFlags ))) return FALSE;
603
604 /* Remove item */
605
606 FreeMenuText(pMenu,item);
607 if (bRecurse && item->spSubMenu)
608 {
609 IntDestroyMenuObject(item->spSubMenu, bRecurse);
610 }
612 if (--pMenu->cItems == 0)
613 {
614 DesktopHeapFree(pMenu->head.rpdesk, pMenu->rgItems );
615 pMenu->rgItems = NULL;
616 }
617 else
618 {
619 while (nPos < pMenu->cItems)
620 {
621 *item = *(item+1);
622 item++;
623 nPos++;
624 }
625 newItems = DesktopHeapReAlloc(pMenu->head.rpdesk, pMenu->rgItems, pMenu->cItems * sizeof(ITEM));
626 if (newItems)
627 {
628 pMenu->rgItems = newItems;
629 }
630 }
631 return TRUE;
632}
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:183
_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 5447 of file menu.c.

5451{
5452 PMENU OldMenu, NewMenu = NULL;
5453
5454 if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
5455 {
5456 ERR("SetMenu: Window is a Child 0x%p!\n",UserHMGetHandle(Wnd));
5458 return FALSE;
5459 }
5460
5461 *Changed = (UlongToHandle(Wnd->IDMenu) != Menu);
5462 if (! *Changed)
5463 {
5464 return TRUE;
5465 }
5466
5467 if (Wnd->IDMenu)
5468 {
5469 OldMenu = IntGetMenuObject(UlongToHandle(Wnd->IDMenu));
5470 ASSERT(NULL == OldMenu || OldMenu->hWnd == UserHMGetHandle(Wnd));
5471 }
5472 else
5473 {
5474 OldMenu = NULL;
5475 }
5476
5477 if (NULL != Menu)
5478 {
5479 NewMenu = IntGetMenuObject(Menu);
5480 if (NULL == NewMenu)
5481 {
5482 if (NULL != OldMenu)
5483 {
5484 IntReleaseMenuObject(OldMenu);
5485 }
5487 return FALSE;
5488 }
5489 if (NULL != NewMenu->hWnd)
5490 {
5491 /* Can't use the same menu for two windows */
5492 if (NULL != OldMenu)
5493 {
5494 IntReleaseMenuObject(OldMenu);
5495 }
5497 return FALSE;
5498 }
5499
5500 }
5501
5502 Wnd->IDMenu = (UINT_PTR) Menu;
5503 if (NULL != NewMenu)
5504 {
5505 NewMenu->hWnd = UserHMGetHandle(Wnd);
5506 IntReleaseMenuObject(NewMenu);
5507 }
5508 if (NULL != OldMenu)
5509 {
5510 OldMenu->hWnd = NULL;
5511 IntReleaseMenuObject(OldMenu);
5512 }
5513
5514 return TRUE;
5515}
#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:706
UINT_PTR IDMenu
Definition: ntuser.h:731
PMENU FASTCALL IntGetMenuObject(HMENU hMenu)
Definition: menu.c:192
#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 1033 of file menu.c.

1034{
1035 PMENU SubMenuObject;
1036 BOOL circref = FALSE;
1037
1038 if(!MenuItem || !MenuObject || !lpmii)
1039 {
1040 return FALSE;
1041 }
1042 if ( lpmii->fMask & MIIM_FTYPE )
1043 {
1044 MenuItem->fType &= ~MENUITEMINFO_TYPE_MASK;
1045 MenuItem->fType |= lpmii->fType & MENUITEMINFO_TYPE_MASK;
1046 }
1047 if (lpmii->fMask & MIIM_TYPE)
1048 {
1049 #if 0
1050 if (lpmii->fMask & ( MIIM_STRING | MIIM_FTYPE | MIIM_BITMAP))
1051 {
1052 ERR("IntSetMenuItemInfo: Invalid combination of fMask bits used\n");
1054 /* This does not happen on Win9x/ME */
1056 return FALSE;
1057 }
1058 #endif
1059 /*
1060 * Delete the menu item type when changing type from
1061 * MF_STRING.
1062 */
1063 if (MenuItem->fType != lpmii->fType &&
1064 MENU_ITEM_TYPE(MenuItem->fType) == MFT_STRING)
1065 {
1066 FreeMenuText(MenuObject,MenuItem);
1067 RtlInitUnicodeString(&MenuItem->lpstr, NULL);
1068 MenuItem->Xlpstr = NULL;
1069 }
1070 if(lpmii->fType & MFT_BITMAP)
1071 {
1072 if(lpmii->hbmpItem)
1073 MenuItem->hbmp = lpmii->hbmpItem;
1074 else
1075 { /* Win 9x/Me stuff */
1076 MenuItem->hbmp = (HBITMAP)((ULONG_PTR)(LOWORD(lpmii->dwTypeData)));
1077 }
1078 lpmii->dwTypeData = 0;
1079 }
1080 }
1081 if(lpmii->fMask & MIIM_BITMAP)
1082 {
1083 MenuItem->hbmp = lpmii->hbmpItem;
1084 if (MenuItem->hbmp <= HBMMENU_POPUP_MINIMIZE && MenuItem->hbmp >= HBMMENU_CALLBACK)
1085 MenuItem->fState |= MFS_HBMMENUBMP;
1086 else
1087 MenuItem->fState &= ~MFS_HBMMENUBMP;
1088 }
1089 if(lpmii->fMask & MIIM_CHECKMARKS)
1090 {
1091 MenuItem->hbmpChecked = lpmii->hbmpChecked;
1092 MenuItem->hbmpUnchecked = lpmii->hbmpUnchecked;
1093 }
1094 if(lpmii->fMask & MIIM_DATA)
1095 {
1096 MenuItem->dwItemData = lpmii->dwItemData;
1097 }
1098 if(lpmii->fMask & MIIM_ID)
1099 {
1100 MenuItem->wID = lpmii->wID;
1101 }
1102 if(lpmii->fMask & MIIM_STATE)
1103 {
1104 /* Remove MFS_DEFAULT flag from all other menu items if this item
1105 has the MFS_DEFAULT state */
1106 if(lpmii->fState & MFS_DEFAULT)
1107 UserSetMenuDefaultItem(MenuObject, -1, 0);
1108 /* Update the menu item state flags */
1109 UpdateMenuItemState(MenuItem->fState, lpmii->fState);
1110 }
1111
1112 if(lpmii->fMask & MIIM_SUBMENU)
1113 {
1114 if (lpmii->hSubMenu)
1115 {
1116 SubMenuObject = UserGetMenuObject(lpmii->hSubMenu);
1117 if ( SubMenuObject && !(UserObjectInDestroy(lpmii->hSubMenu)) )
1118 {
1121 if (MenuObject == SubMenuObject)
1122 {
1123 HANDLE hMenu;
1124 ERR("Pop Up Menu Double Trouble!\n");
1125 SubMenuObject = IntCreateMenu(&hMenu,
1126 FALSE,
1127 MenuObject->head.rpdesk,
1128 (PPROCESSINFO)MenuObject->head.hTaskWow); // It will be marked.
1129 if (!SubMenuObject) return FALSE;
1130 IntReleaseMenuObject(SubMenuObject); // This will be referenced again after insertion.
1131 circref = TRUE;
1132 }
1133 if ( MENU_depth( SubMenuObject, 0) > MAXMENUDEPTH )
1134 {
1135 ERR( "Loop detected in menu hierarchy or maximum menu depth exceeded!\n");
1136 if (circref) IntDestroyMenuObject(SubMenuObject, FALSE);
1137 return FALSE;
1138 }
1139 /* Make sure the submenu is marked as a popup menu */
1140 SubMenuObject->fFlags |= MNF_POPUP;
1141 // Now fix the test_subpopup_locked_by_menu tests....
1142 if (MenuItem->spSubMenu) IntReleaseMenuObject(MenuItem->spSubMenu);
1143 MenuItem->spSubMenu = SubMenuObject;
1144 UserReferenceObject(SubMenuObject);
1145 }
1146 else
1147 {
1149 return FALSE;
1150 }
1151 }
1152 else
1153 { // If submenu just dereference it.
1154 if (MenuItem->spSubMenu) IntReleaseMenuObject(MenuItem->spSubMenu);
1155 MenuItem->spSubMenu = NULL;
1156 }
1157 }
1158
1159 if ((lpmii->fMask & MIIM_STRING) ||
1160 ((lpmii->fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(lpmii->fType) == MF_STRING)))
1161 {
1162 /* free the string when used */
1163 FreeMenuText(MenuObject,MenuItem);
1164 RtlInitUnicodeString(&MenuItem->lpstr, NULL);
1165 MenuItem->Xlpstr = NULL;
1166
1167 if(lpmii->dwTypeData && lpmii->cch && lpstr && lpstr->Buffer)
1168 {
1170
1171 if (!NT_VERIFY(lpmii->cch <= UNICODE_STRING_MAX_CHARS))
1172 {
1173 return FALSE;
1174 }
1175
1176 Source.Length = Source.MaximumLength = (USHORT)(lpmii->cch * sizeof(WCHAR));
1177 Source.Buffer = lpmii->dwTypeData;
1178
1179 MenuItem->lpstr.Buffer = DesktopHeapAlloc( MenuObject->head.rpdesk, Source.Length + sizeof(WCHAR));
1180 if(MenuItem->lpstr.Buffer != NULL)
1181 {
1182 MenuItem->lpstr.Length = 0;
1183 MenuItem->lpstr.MaximumLength = Source.Length + sizeof(WCHAR);
1184 RtlCopyUnicodeString(&MenuItem->lpstr, &Source);
1185 MenuItem->lpstr.Buffer[MenuItem->lpstr.Length / sizeof(WCHAR)] = 0;
1186
1187 MenuItem->cch = MenuItem->lpstr.Length / sizeof(WCHAR);
1188 MenuItem->Xlpstr = (USHORT*)MenuItem->lpstr.Buffer;
1189 }
1190 }
1191 }
1192
1193 if( !(MenuObject->fFlags & MNF_SYSMENU) &&
1194 !MenuItem->Xlpstr &&
1195 !lpmii->dwTypeData &&
1196 !(MenuItem->fType & MFT_OWNERDRAW) &&
1197 !MenuItem->hbmp)
1198 MenuItem->fType |= MFT_SEPARATOR;
1199
1200 if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
1201 {
1202 MenuItem->xItem = lpmii->Rect.left;
1203 MenuItem->yItem = lpmii->Rect.top;
1204 MenuItem->cxItem = lpmii->Rect.right; // Do this for now......
1205 MenuItem->cyItem = lpmii->Rect.bottom;
1206 MenuItem->dxTab = lpmii->dxTab;
1207 lpmii->lpstr = MenuItem->lpstr.Buffer; /* Send back new allocated string or zero */
1208 MenuItem->cxBmp = lpmii->maxBmpSize.cx;
1209 MenuItem->cyBmp = lpmii->maxBmpSize.cy;
1210 }
1211
1212 return TRUE;
1213}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define MNF_SYSMENU
Definition: ntuser.h:410
#define MFS_HBMMENUBMP
Definition: ntuser.h:368
#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
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
USHORT MaximumLength
Definition: env_spec_w32.h:370
HBITMAP hbmp
Definition: ntuser.h:388
INT cyBmp
Definition: ntuser.h:390
ULONG yItem
Definition: ntuser.h:382
DWORD_PTR dwItemData
Definition: ntuser.h:380
UINT wID
Definition: ntuser.h:374
ULONG dxTab
Definition: ntuser.h:385
UNICODE_STRING lpstr
Definition: ntuser.h:392
USHORT * Xlpstr
Definition: ntuser.h:378
ULONG xItem
Definition: ntuser.h:381
INT cxBmp
Definition: ntuser.h:389
ULONG cxItem
Definition: ntuser.h:383
ULONG cyItem
Definition: ntuser.h:384
ULONG cch
Definition: ntuser.h:379
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
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
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:1274
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:47
#define UpdateMenuItemState(state, change)
Definition: menu.c:95
PMENU FASTCALL IntCreateMenu(_Out_ PHANDLE Handle, _In_ BOOL IsMenuBar, _In_ PDESKTOP Desktop, _In_ PPROCESSINFO ppi)
Definition: menu.c:729
int FASTCALL MENU_depth(PMENU pmenu, int depth)
Definition: menu.c:404
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:703
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
#define MIIM_STRING
Definition: winuser.h:727
#define MIIM_ID
Definition: winuser.h:722
#define HBMMENU_POPUP_MINIMIZE
Definition: winuser.h:2640
#define MIIM_CHECKMARKS
Definition: winuser.h:724
#define MF_STRING
Definition: winuser.h:138
#define MIIM_FTYPE
Definition: winuser.h:729
#define MFT_SEPARATOR
Definition: winuser.h:744
#define MIIM_STATE
Definition: winuser.h:721
#define MFS_DEFAULT
Definition: winuser.h:748
#define MFT_OWNERDRAW
Definition: winuser.h:741
#define MIIM_SUBMENU
Definition: winuser.h:723
#define MIIM_BITMAP
Definition: winuser.h:728
#define MFT_BITMAP
Definition: winuser.h:738
#define MFT_STRING
Definition: winuser.h:746
#define HBMMENU_CALLBACK
Definition: winuser.h:2630
#define MIIM_DATA
Definition: winuser.h:726
#define MIIM_TYPE
Definition: winuser.h:725
#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 4549 of file menu.c.

4551{
4552 BOOL ret = FALSE;
4554
4555 if (pti != pWnd->head.pti)
4556 {
4557 ERR("Must be the same pti!\n");
4558 return ret;
4559 }
4560
4561 TRACE("hmenu %p flags %04x (%d,%d) hwnd %p lpTpm %p \n", //rect %s\n",
4562 UserHMGetHandle(menu), wFlags, x, y, UserHMGetHandle(pWnd), lpTpm); //,
4563 //lpTpm ? wine_dbgstr_rect( &lpTpm->rcExclude) : "-" );
4564
4565 if (menu->hWnd && IntIsWindow(menu->hWnd))
4566 {
4568 return FALSE;
4569 }
4570
4571 if (MENU_InitPopup( pWnd, menu, wFlags ))
4572 {
4573 MENU_InitTracking(pWnd, menu, TRUE, wFlags);
4574
4575 /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
4576 if (!(wFlags & TPM_NONOTIFY))
4577 {
4579 }
4580
4581 if (menu->fFlags & MNF_SYSMENU)
4582 MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
4583
4584 if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y, lpTpm ? &lpTpm->rcExclude : NULL))
4585 ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd);
4586 else
4587 {
4589 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4590 co_UserSetCapture(NULL); /* release the capture */
4591 }
4592
4594
4595 if (menu->hWnd)
4596 {
4597 PWND pwndM = ValidateHwndNoErr( menu->hWnd );
4598 if (pwndM) // wine hack around this with their destroy function.
4599 {
4600 if (!(pWnd->state & WNDS_DESTROYED))
4601 co_UserDestroyWindow( pwndM ); // Fix wrong error return.
4602 }
4603 menu->hWnd = 0;
4604
4605 if (!(wFlags & TPM_NONOTIFY))
4606 {
4607 co_IntSendMessage( UserHMGetHandle(pWnd), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(menu),
4608 MAKELPARAM(0, IS_SYSTEM_MENU(menu) ? MF_SYSMENU : 0));
4609 }
4610 }
4611 }
4612 return ret;
4613}
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1457
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:636
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3584
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2495
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
UINT style
Definition: ntuser.h:580
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
PCLS pcls
Definition: ntuser.h:720
THRDESKHEAD head
Definition: ntuser.h:695
DWORD state
Definition: ntuser.h:701
RECT rcExclude
Definition: winuser.h:3576
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2853
#define IS_SYSTEM_MENU(MenuInfo)
Definition: menu.c:60
static BOOL MENU_InitPopup(PWND pWndOwner, PMENU menu, UINT flags)
Definition: menu.c:2781
static BOOL FASTCALL MENU_ExitTracking(PWND pWnd, BOOL bPopup, UINT wFlags)
Definition: menu.c:4436
#define TPM_POPUPMENU
Definition: menu.c:90
static BOOL FASTCALL MENU_ShowPopup(PWND pwndOwner, PMENU menu, UINT id, UINT flags, INT x, INT y, const RECT *pExclude)
Definition: menu.c:2939
void FASTCALL MENU_InitSysMenuPopup(PMENU menu, DWORD style, DWORD clsStyle, LONG HitTest)
Definition: menu.c:1362
static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
Definition: menu.c:4042
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4376
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1445
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:176
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define MF_SYSMENU
Definition: winuser.h:141
#define TPM_NONOTIFY
Definition: winuser.h:2386
#define WM_INITMENUPOPUP
Definition: winuser.h:1746
#define HTSYSMENU
Definition: winuser.h:2477

Referenced by IntDefWindowProc(), and NtUserTrackPopupMenuEx().

◆ MENU_DrawMenuBar()

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

Definition at line 2742 of file menu.c.

2743{
2744 HFONT hfontOld = 0;
2746
2747 if (lppop == NULL)
2748 {
2749 // No menu. Do not reserve any space
2750 return 0;
2751 }
2752
2753 if (lprect == NULL)
2754 {
2756 }
2757
2758 if (suppress_draw)
2759 {
2760 hfontOld = NtGdiSelectFont(hDC, ghMenuFont);
2761
2762 MENU_MenuBarCalcSize(hDC, lprect, lppop, pWnd);
2763
2764 lprect->bottom = lprect->top + lppop->cyMenu;
2765
2766 if (hfontOld) NtGdiSelectFont( hDC, hfontOld);
2767
2768 return lppop->cyMenu;
2769 }
2770 else
2771 {
2772 return IntDrawMenuBarTemp(pWnd, hDC, lprect, lppop, NULL);
2773 }
2774}
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:2685
HFONT ghMenuFont
Definition: menu.c:16
static void MENU_MenuBarCalcSize(HDC hdc, LPRECT lprect, PMENU lppop, PWND pwndOwner)
Definition: menu.c:2101
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:213
#define SM_CYMENU
Definition: winuser.h:976

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

◆ MENU_EndMenu()

void MENU_EndMenu ( PWND  pwnd)

Definition at line 2662 of file menu.c.

2663{
2664 PMENU menu = NULL;
2666 if ( menu && ( UserHMGetHandle(pwnd) == menu->hWnd || pwnd == menu->spwndNotify ) )
2667 {
2669 {
2671
2672 if (fInEndMenu)
2673 {
2674 ERR("Already in End loop\n");
2675 return;
2676 }
2677
2678 fInEndMenu = TRUE;
2680 }
2681 }
2682}
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:1345
#define WM_CANCELMODE
Definition: winuser.h:1635

Referenced by IntDefWindowProc().

◆ MENU_FindItem()

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

Definition at line 507 of file menu.c.

508{
509 MENU *menu = *pmenu;
510 ITEM *fallback = NULL;
511 UINT fallback_pos = 0;
512 UINT i;
513
514 if (!menu) return NULL;
515
516 if (wFlags & MF_BYPOSITION)
517 {
518 if (!menu->cItems) return NULL;
519 if (*nPos >= menu->cItems) return NULL;
520 return &menu->rgItems[*nPos];
521 }
522 else
523 {
524 PITEM item = menu->rgItems;
525 for (i = 0; i < menu->cItems; i++, item++)
526 {
527 if (item->spSubMenu)
528 {
529 PMENU psubmenu = item->spSubMenu;//VerifyMenu(item->spSubMenu);
530 PITEM subitem = MENU_FindItem( &psubmenu, nPos, wFlags );
531 if (subitem)
532 {
533 *pmenu = psubmenu;
534 return subitem;
535 }
536 else if (item->wID == *nPos)
537 {
538 /* fallback to this item if nothing else found */
539 fallback_pos = i;
540 fallback = item;
541 }
542 }
543 else if (item->wID == *nPos)
544 {
545 *nPos = i;
546 return item;
547 }
548 }
549 }
550
551 if (fallback)
552 *nPos = fallback_pos;
553
554 return fallback;
555}
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 1362 of file menu.c.

1363{
1364 BOOL gray;
1365 UINT DefItem;
1366
1367 gray = !(style & WS_THICKFRAME) || (style & (WS_MAXIMIZE | WS_MINIMIZE));
1368 IntEnableMenuItem( menu, SC_SIZE, (gray ? MF_GRAYED : MF_ENABLED) );
1369 gray = ((style & (WS_MAXIMIZE | WS_MINIMIZE)) != 0);
1370 IntEnableMenuItem( menu, SC_MOVE, (gray ? MF_GRAYED : MF_ENABLED) );
1371 gray = !(style & WS_MINIMIZEBOX) || (style & WS_MINIMIZE);
1373 gray = !(style & WS_MAXIMIZEBOX) || (style & WS_MAXIMIZE);
1375 gray = !(style & (WS_MAXIMIZE | WS_MINIMIZE));
1376 IntEnableMenuItem( menu, SC_RESTORE, (gray ? MF_GRAYED : MF_ENABLED) );
1377 gray = (clsStyle & CS_NOCLOSE) != 0;
1378
1379 /* The menu item must keep its state if it's disabled */
1380 if(gray)
1382
1383 /* Set default menu item */
1384 if(style & WS_MINIMIZE) DefItem = SC_RESTORE;
1385 else if(HitTest == HTCAPTION) DefItem = ((style & (WS_MAXIMIZE | WS_MINIMIZE)) ? SC_RESTORE : SC_MAXIMIZE);
1386 else DefItem = SC_CLOSE;
1387
1388 UserSetMenuDefaultItem(menu, DefItem, MF_BYCOMMAND);
1389}
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:1217
#define HTCAPTION
Definition: winuser.h:2476
#define SC_SIZE
Definition: winuser.h:2584
#define SC_MINIMIZE
Definition: winuser.h:2586
#define MF_ENABLED
Definition: winuser.h:128
#define SC_CLOSE
Definition: winuser.h:2592
#define SC_MOVE
Definition: winuser.h:2585
#define SC_RESTORE
Definition: winuser.h:2598
#define CS_NOCLOSE
Definition: winuser.h:654
#define SC_MAXIMIZE
Definition: winuser.h:2588
#define MF_GRAYED
Definition: winuser.h:129

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

◆ MENU_IsMenuActive()

PWND MENU_IsMenuActive ( VOID  )

Definition at line 2650 of file menu.c.

2651{
2653}

Referenced by IntDefWindowProc().

◆ MENU_TrackKbdMenuBar()

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

Definition at line 4488 of file menu.c.

4489{
4490 UINT uItem = NO_SELECTED_ITEM;
4491 PMENU TrackMenu;
4493
4494 TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", UserHMGetHandle(pwnd), wParam, wChar);
4495
4496 /* find window that has a menu */
4497
4498 while (!( (pwnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD ) )
4499 if (!(pwnd = UserGetAncestor( pwnd, GA_PARENT ))) return;
4500
4501 /* check if we have to track a system menu */
4502
4503 TrackMenu = IntGetMenu( UserHMGetHandle(pwnd) );
4504 if (!TrackMenu || (pwnd->style & WS_MINIMIZE) != 0 || wChar == ' ' )
4505 {
4506 if (!(pwnd->style & WS_SYSMENU)) return;
4507 TrackMenu = get_win_sys_menu( UserHMGetHandle(pwnd) );
4508 uItem = 0;
4509 wParam |= HTSYSMENU; /* prevent item lookup */
4510 }
4511
4512 if (!VerifyMenu( TrackMenu )) return;
4513
4514 MENU_InitTracking( pwnd, TrackMenu, FALSE, wFlags );
4515
4516 /* fetch the window menu again, it may have changed */
4517 TrackMenu = (wParam & HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pwnd) ) : IntGetMenu( UserHMGetHandle(pwnd) );
4518
4519 if( wChar && wChar != ' ' )
4520 {
4521 uItem = MENU_FindItemByKey( pwnd, TrackMenu, wChar, (wParam & HTSYSMENU) );
4522 if ( uItem >= (UINT)(-2) )
4523 {
4524 if( uItem == (UINT)(-1) ) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0);
4525 /* schedule end of menu tracking */
4526 wFlags |= TF_ENDMENU;
4527 goto track_menu;
4528 }
4529 }
4530
4531 MENU_SelectItem( pwnd, TrackMenu, uItem, TRUE, 0 );
4532
4533 if (!(wParam & HTSYSMENU) || wChar == ' ')
4534 {
4535 if( uItem == NO_SELECTED_ITEM )
4536 MENU_MoveSelection( pwnd, TrackMenu, ITEM_NEXT );
4537 else
4539 }
4540
4541track_menu:
4542 MENU_TrackMenu( TrackMenu, wFlags, 0, 0, pwnd );
4544}
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:3341
#define TF_ENDMENU
Definition: menu.c:35
PMENU get_win_sys_menu(HWND hwnd)
Definition: menu.c:258
PMENU FASTCALL VerifyMenu(PMENU pMenu)
Definition: menu.c:201
static void FASTCALL MENU_MoveSelection(PWND pwndOwner, PMENU menu, INT offset)
Definition: menu.c:3226
static UINT FASTCALL MENU_FindItemByKey(PWND WndOwner, PMENU menu, WCHAR Key, BOOL ForceMenuChar)
Definition: menu.c:1535
static void FASTCALL MENU_SelectItem(PWND pwndOwner, PMENU menu, UINT wIndex, BOOL sendMenuSelect, PMENU topmenu)
Definition: menu.c:3139
PMENU WINAPI IntGetMenu(HWND hWnd)
Definition: menu.c:248
#define ITEM_NEXT
Definition: menu.c:93
#define GA_PARENT
Definition: winuser.h:2788
#define VK_RETURN
Definition: winuser.h:2201
#define TPM_LEFTALIGN
Definition: winuser.h:2377
#define TPM_LEFTBUTTON
Definition: winuser.h:2379
#define WM_KEYDOWN
Definition: winuser.h:1715

Referenced by DefWndHandleSysCommand().

◆ MENU_TrackMouseMenuBar()

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

Definition at line 4458 of file menu.c.

4459{
4460 PMENU pMenu = (ht == HTSYSMENU) ? IntGetSystemMenu(pWnd, FALSE) : IntGetMenu( UserHMGetHandle(pWnd) ); // See 74276 and CORE-12801
4462
4463 TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", pWnd, ht, pt.x, pt.y);
4464
4465 if (pWnd->ExStyle & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
4466 if (VerifyMenu(pMenu))
4467 {
4468 /* map point to parent client coordinates */
4471 {
4473 }
4474
4475 MENU_InitTracking(pWnd, pMenu, FALSE, wFlags);
4476 /* fetch the window menu again, it may have changed */
4477 pMenu = (ht == HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pWnd) ) : IntGetMenu( UserHMGetHandle(pWnd) );
4478 MENU_TrackMenu(pMenu, wFlags, pt.x, pt.y, pWnd);
4480 }
4481}
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:213
DWORD ExStyle
Definition: ntuser.h:704
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
PMENU FASTCALL IntGetSystemMenu(PWND Window, BOOL bRevert)
Definition: menu.c:5371
#define TPM_BUTTONDOWN
Definition: menu.c:89
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define TPM_VERTICAL
Definition: winuser.h:2382

Referenced by DefWndHandleSysCommand().

◆ MenuInit()

BOOL MenuInit ( VOID  )

Definition at line 359 of file menu.c.

360{
361 NONCLIENTMETRICSW ncm;
362
363 /* get the menu font */
364 if (!ghMenuFont || !ghMenuFontBold)
365 {
366 ncm.cbSize = sizeof(ncm);
367 if(!UserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0))
368 {
369 ERR("MenuInit(): SystemParametersInfo(SPI_GETNONCLIENTMETRICS) failed!\n");
370 return FALSE;
371 }
372
373 ghMenuFont = GreCreateFontIndirectW(&ncm.lfMenuFont);
374 if (ghMenuFont == NULL)
375 {
376 ERR("MenuInit(): CreateFontIndirectW(hMenuFont) failed!\n");
377 return FALSE;
378 }
379 ncm.lfMenuFont.lfWeight = min(ncm.lfMenuFont.lfWeight + (FW_BOLD - FW_NORMAL), FW_HEAVY);
380 ghMenuFontBold = GreCreateFontIndirectW(&ncm.lfMenuFont);
381 if (ghMenuFontBold == NULL)
382 {
383 ERR("MenuInit(): CreateFontIndirectW(hMenuFontBold) failed!\n");
386 return FALSE;
387 }
388
391
393 }
394
395 return TRUE;
396}
#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:2105
#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 4619 of file menu.c.

4625{
4626 PPOPUPMENU pPopupMenu;
4627
4628 *lResult = 0;
4629
4630 TRACE("PMWP : pwnd=%x msg=%d wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
4631
4632 if (Wnd)
4633 {
4634 if (!Wnd->fnid)
4635 {
4636 if (Message != WM_NCCREATE)
4637 {
4638 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4639 return TRUE;
4640 }
4641 Wnd->fnid = FNID_MENU;
4642 pPopupMenu = DesktopHeapAlloc( Wnd->head.rpdesk, sizeof(POPUPMENU) );
4643 if (pPopupMenu == NULL)
4644 {
4645 return TRUE;
4646 }
4647 pPopupMenu->posSelectedItem = NO_SELECTED_ITEM;
4648 pPopupMenu->spwndPopupMenu = Wnd;
4649 ((PMENUWND)Wnd)->ppopupmenu = pPopupMenu;
4650 TRACE("Pop Up Menu is Setup! Msg %d\n",Message);
4651 *lResult = 1;
4652 return TRUE;
4653 }
4654 else
4655 {
4656 if (Wnd->fnid != FNID_MENU)
4657 {
4658 ERR("Wrong window class for Menu! fnid %x\n",Wnd->fnid);
4659 return TRUE;
4660 }
4661 pPopupMenu = ((PMENUWND)Wnd)->ppopupmenu;
4662 }
4663 }
4664
4665 switch(Message)
4666 {
4667 case WM_CREATE:
4668 {
4670 pPopupMenu->spmenu = UserGetMenuObject(cs->lpCreateParams);
4671 if (pPopupMenu->spmenu)
4672 {
4673 UserReferenceObject(pPopupMenu->spmenu);
4674 }
4675 break;
4676 }
4677
4678 case WM_MOUSEACTIVATE: /* We don't want to be activated */
4679 *lResult = MA_NOACTIVATE;
4680 break;
4681
4682 case WM_PAINT:
4683 {
4684 PAINTSTRUCT ps;
4685 IntBeginPaint(Wnd, &ps);
4686 MENU_DrawPopupMenu(Wnd, ps.hdc, pPopupMenu->spmenu);
4687 IntEndPaint(Wnd, &ps);
4688 break;
4689 }
4690
4691 case WM_PRINTCLIENT:
4692 {
4693 MENU_DrawPopupMenu( Wnd, (HDC)wParam, pPopupMenu->spmenu);
4694 break;
4695 }
4696
4697 case WM_ERASEBKGND:
4698 *lResult = 1;
4699 break;
4700
4701 case WM_DESTROY:
4702 /* zero out global pointer in case resident popup window was destroyed. */
4703 if (pPopupMenu)
4704 {
4705 if (UserHMGetHandle(Wnd) == top_popup)
4706 {
4707 top_popup = NULL;
4709 }
4710 }
4711 else
4712 {
4713 ERR("No Window Pop Up!\n");
4714 }
4715 break;
4716
4717 case WM_NCDESTROY:
4718 {
4719 if (pPopupMenu->spmenu)
4720 {
4721 IntReleaseMenuObject(pPopupMenu->spmenu);
4722 }
4723 DesktopHeapFree(Wnd->head.rpdesk, pPopupMenu );
4724 ((PMENUWND)Wnd)->ppopupmenu = 0;
4725 Wnd->fnid = FNID_DESTROY;
4726 break;
4727 }
4728
4729 case MM_SETMENUHANDLE: // wine'isms
4730 case MN_SETHMENU:
4731 {
4733 if (!pmenu)
4734 {
4735 ERR("Bad Menu Handle\n");
4736 break;
4737 }
4738 UserReferenceObject(pmenu);
4739 if (pPopupMenu->spmenu)
4740 {
4741 IntReleaseMenuObject(pPopupMenu->spmenu);
4742 }
4743 pPopupMenu->spmenu = pmenu;
4744 break;
4745 }
4746
4747 case MM_GETMENUHANDLE: // wine'isms
4748 case MN_GETHMENU:
4749 *lResult = (LRESULT)(pPopupMenu ? (pPopupMenu->spmenu ? UserHMGetHandle(pPopupMenu->spmenu) : NULL) : NULL);
4750 break;
4751
4752 default:
4753 if (Message > MN_GETHMENU && Message < MN_GETHMENU+19)
4754 {
4755 ERR("Someone is passing unknown menu messages %d\n",Message);
4756 }
4757 TRACE("PMWP to IDWP %d\n",Message);
4758 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4759 break;
4760 }
4761
4762 return TRUE;
4763}
LPARAM lParam
Definition: combotst.c:139
static const WCHAR Message[]
Definition: register.c:74
#define cs
Definition: i386-dis.c:442
struct _MENUWND * PMENUWND
#define FNID_DESTROY
Definition: ntuser.h:898
#define FNID_MENU
Definition: ntuser.h:861
static HDC
Definition: imagelist.c:92
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:535
#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:709
PMENU spmenu
Definition: ntuser.h:473
UINT posSelectedItem
Definition: ntuser.h:478
struct _WND * spwndPopupMenu
Definition: ntuser.h:470
#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:2599
#define MM_SETMENUHANDLE
Definition: menu.c:30
#define MM_GETMENUHANDLE
Definition: menu.c:31
#define WM_PAINT
Definition: winuser.h:1620
#define WM_ERASEBKGND
Definition: winuser.h:1625
#define WM_CREATE
Definition: winuser.h:1608
#define MN_GETHMENU
Definition: winuser.h:1773
#define MA_NOACTIVATE
Definition: winuser.h:2503
#define WM_NCCREATE
Definition: winuser.h:1683
#define WM_MOUSEACTIVATE
Definition: winuser.h:1637
#define WM_NCDESTROY
Definition: winuser.h:1684
#define WM_DESTROY
Definition: winuser.h:1609

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

◆ UserDestroyMenuObject()

BOOLEAN UserDestroyMenuObject ( PVOID  Object)

Definition at line 311 of file menu.c.

312{
314}
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object