ReactOS 0.4.16-dev-136-g52192f1
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: precomp.h:57
#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:231
#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 5031 of file menu.c.

5032{
5033 PMENU menu, pSubTarget;
5034 UINT Pos;
5035 if (((*hMenu)==(HMENU)0xffff) ||(!(menu = UserGetMenuObject(*hMenu))))
5036 return NO_SELECTED_ITEM;
5037
5038 pSubTarget = UserGetMenuObject(hSubTarget);
5039
5040 Pos = MENU_FindSubMenu(&menu, pSubTarget );
5041
5042 *hMenu = (menu ? UserHMGetHandle(menu) : NULL);
5043
5044 return Pos;
5045}
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 4991 of file menu.c.

4992{
4993 PMENU MenuObject;
4994 PITEM pItem;
4995
4996 if (!(MenuObject = UserGetMenuObject(hMenu)))
4997 {
4998 return (UINT)-1;
4999 }
5000
5001 if (!(pItem = MENU_FindItem( &MenuObject, &uId, uFlags ))) return -1;
5002
5003 if (pItem->spSubMenu)
5004 {
5005 return (pItem->spSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|MF_POPUP) & 0xff);
5006 }
5007 else
5008 return (pItem->fType | pItem->fState);
5009}
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 5399 of file menu.c.

5400{
5401 PMENU Menu;
5402
5403 if (bRevert)
5404 {
5405 if (Window->SystemMenu)
5406 {
5407 Menu = UserGetMenuObject(Window->SystemMenu);
5408 if (Menu && !(Menu->fFlags & MNF_SYSDESKMN))
5409 {
5411 Window->SystemMenu = NULL;
5412 }
5413 }
5414 }
5415 else
5416 {
5417 Menu = Window->SystemMenu ? UserGetMenuObject(Window->SystemMenu) : NULL;
5418 if ((!Menu || Menu->fFlags & MNF_SYSDESKMN) && Window->style & WS_SYSMENU)
5419 {
5421 Window->SystemMenu = Menu ? UserHMGetHandle(Menu) : NULL;
5422 }
5423 }
5424
5425 if (Window->SystemMenu)
5426 {
5427 HMENU hMenu = IntGetSubMenu( Window->SystemMenu, 0);
5428 /* Store the dummy sysmenu handle to facilitate the refresh */
5429 /* of the close button if the SC_CLOSE item change */
5430 Menu = UserGetMenuObject(hMenu);
5431 if (Menu)
5432 {
5433 Menu->spwndNotify = Window;
5434 Menu->fFlags |= MNF_SYSSUBMENU;
5435 }
5436 return Menu;
5437 }
5438 return NULL;
5439}
#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:5294
HMENU FASTCALL IntGetSubMenu(HMENU hMenu, int nPos)
Definition: menu.c:5011

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:3324

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

5099{
5100 PITEM MenuItem;
5101 BOOL Ret;
5102
5103 if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5104 {
5106 return FALSE;
5107 }
5108 if (SetOrGet)
5109 {
5110 Ret = IntSetMenuItemInfo(Menu, MenuItem, ItemInfo, lpstr);
5111 }
5112 else
5113 {
5114 Ret = IntGetMenuItemInfo(Menu, MenuItem, ItemInfo);
5115 }
5116 return Ret;
5117}
_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 5475 of file menu.c.

5479{
5480 PMENU OldMenu, NewMenu = NULL;
5481
5482 if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
5483 {
5484 ERR("SetMenu: Window is a Child 0x%p!\n",UserHMGetHandle(Wnd));
5486 return FALSE;
5487 }
5488
5489 *Changed = (UlongToHandle(Wnd->IDMenu) != Menu);
5490 if (! *Changed)
5491 {
5492 return TRUE;
5493 }
5494
5495 if (Wnd->IDMenu)
5496 {
5497 OldMenu = IntGetMenuObject(UlongToHandle(Wnd->IDMenu));
5498 ASSERT(NULL == OldMenu || OldMenu->hWnd == UserHMGetHandle(Wnd));
5499 }
5500 else
5501 {
5502 OldMenu = NULL;
5503 }
5504
5505 if (NULL != Menu)
5506 {
5507 NewMenu = IntGetMenuObject(Menu);
5508 if (NULL == NewMenu)
5509 {
5510 if (NULL != OldMenu)
5511 {
5512 IntReleaseMenuObject(OldMenu);
5513 }
5515 return FALSE;
5516 }
5517 if (NULL != NewMenu->hWnd)
5518 {
5519 /* Can't use the same menu for two windows */
5520 if (NULL != OldMenu)
5521 {
5522 IntReleaseMenuObject(OldMenu);
5523 }
5525 return FALSE;
5526 }
5527
5528 }
5529
5530 Wnd->IDMenu = (UINT_PTR) Menu;
5531 if (NULL != NewMenu)
5532 {
5533 NewMenu->hWnd = UserHMGetHandle(Wnd);
5534 IntReleaseMenuObject(NewMenu);
5535 }
5536 if (NULL != OldMenu)
5537 {
5538 OldMenu->hWnd = NULL;
5539 IntReleaseMenuObject(OldMenu);
5540 }
5541
5542 return TRUE;
5543}
#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:730
#define MIIM_ID
Definition: winuser.h:725
#define HBMMENU_POPUP_MINIMIZE
Definition: winuser.h:2643
#define MIIM_CHECKMARKS
Definition: winuser.h:727
#define MF_STRING
Definition: winuser.h:138
#define MIIM_FTYPE
Definition: winuser.h:732
#define MFT_SEPARATOR
Definition: winuser.h:747
#define MIIM_STATE
Definition: winuser.h:724
#define MFS_DEFAULT
Definition: winuser.h:751
#define MFT_OWNERDRAW
Definition: winuser.h:744
#define MIIM_SUBMENU
Definition: winuser.h:726
#define MIIM_BITMAP
Definition: winuser.h:731
#define MFT_BITMAP
Definition: winuser.h:741
#define MFT_STRING
Definition: winuser.h:749
#define HBMMENU_CALLBACK
Definition: winuser.h:2633
#define MIIM_DATA
Definition: winuser.h:729
#define MIIM_TYPE
Definition: winuser.h:728
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3301
__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 4577 of file menu.c.

4579{
4580 BOOL ret = FALSE;
4582
4583 if (pti != pWnd->head.pti)
4584 {
4585 ERR("Must be the same pti!\n");
4586 return ret;
4587 }
4588
4589 TRACE("hmenu %p flags %04x (%d,%d) hwnd %p lpTpm %p \n", //rect %s\n",
4590 UserHMGetHandle(menu), wFlags, x, y, UserHMGetHandle(pWnd), lpTpm); //,
4591 //lpTpm ? wine_dbgstr_rect( &lpTpm->rcExclude) : "-" );
4592
4593 if (menu->hWnd && IntIsWindow(menu->hWnd))
4594 {
4596 return FALSE;
4597 }
4598
4599 if (MENU_InitPopup( pWnd, menu, wFlags ))
4600 {
4601 MENU_InitTracking(pWnd, menu, TRUE, wFlags);
4602
4603 /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
4604 if (!(wFlags & TPM_NONOTIFY))
4605 {
4607 }
4608
4609 if (menu->fFlags & MNF_SYSMENU)
4610 MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
4611
4612 if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y, lpTpm ? &lpTpm->rcExclude : NULL))
4613 ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd);
4614 else
4615 {
4617 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4618 co_UserSetCapture(NULL); /* release the capture */
4619 }
4620
4622
4623 if (menu->hWnd)
4624 {
4625 PWND pwndM = ValidateHwndNoErr( menu->hWnd );
4626 if (pwndM) // wine hack around this with their destroy function.
4627 {
4628 if (!(pWnd->state & WNDS_DESTROYED))
4629 co_UserDestroyWindow( pwndM ); // Fix wrong error return.
4630 }
4631 menu->hWnd = 0;
4632
4633 if (!(wFlags & TPM_NONOTIFY))
4634 {
4635 co_IntSendMessage( UserHMGetHandle(pWnd), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(menu),
4636 MAKELPARAM(0, IS_SYSTEM_MENU(menu) ? MF_SYSMENU : 0));
4637 }
4638 }
4639 }
4640 return ret;
4641}
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1460
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:3590
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2501
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:3579
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2855
#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:4464
#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:4050
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4404
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1495
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:178
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
#define MF_SYSMENU
Definition: winuser.h:141
#define TPM_NONOTIFY
Definition: winuser.h:2389
#define WM_INITMENUPOPUP
Definition: winuser.h:1749
#define HTSYSMENU
Definition: winuser.h:2480

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:214
#define SM_CYMENU
Definition: winuser.h:979

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:1395
#define WM_CANCELMODE
Definition: winuser.h:1638

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:2479
#define SC_SIZE
Definition: winuser.h:2587
#define SC_MINIMIZE
Definition: winuser.h:2589
#define MF_ENABLED
Definition: winuser.h:128
#define SC_CLOSE
Definition: winuser.h:2595
#define SC_MOVE
Definition: winuser.h:2588
#define SC_RESTORE
Definition: winuser.h:2601
#define CS_NOCLOSE
Definition: winuser.h:654
#define SC_MAXIMIZE
Definition: winuser.h:2591
#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 4516 of file menu.c.

4517{
4518 UINT uItem = NO_SELECTED_ITEM;
4519 PMENU TrackMenu;
4521
4522 TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", UserHMGetHandle(pwnd), wParam, wChar);
4523
4524 /* find window that has a menu */
4525
4526 while (!( (pwnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD ) )
4527 if (!(pwnd = UserGetAncestor( pwnd, GA_PARENT ))) return;
4528
4529 /* check if we have to track a system menu */
4530
4531 TrackMenu = IntGetMenu( UserHMGetHandle(pwnd) );
4532 if (!TrackMenu || (pwnd->style & WS_MINIMIZE) != 0 || wChar == ' ' )
4533 {
4534 if (!(pwnd->style & WS_SYSMENU)) return;
4535 TrackMenu = get_win_sys_menu( UserHMGetHandle(pwnd) );
4536 uItem = 0;
4537 wParam |= HTSYSMENU; /* prevent item lookup */
4538 }
4539
4540 if (!VerifyMenu( TrackMenu )) return;
4541
4542 MENU_InitTracking( pwnd, TrackMenu, FALSE, wFlags );
4543
4544 /* fetch the window menu again, it may have changed */
4545 TrackMenu = (wParam & HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pwnd) ) : IntGetMenu( UserHMGetHandle(pwnd) );
4546
4547 if( wChar && wChar != ' ' )
4548 {
4549 uItem = MENU_FindItemByKey( pwnd, TrackMenu, wChar, (wParam & HTSYSMENU) );
4550 if ( uItem >= (UINT)(-2) )
4551 {
4552 if( uItem == (UINT)(-1) ) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0);
4553 /* schedule end of menu tracking */
4554 wFlags |= TF_ENDMENU;
4555 goto track_menu;
4556 }
4557 }
4558
4559 MENU_SelectItem( pwnd, TrackMenu, uItem, TRUE, 0 );
4560
4561 if (!(wParam & HTSYSMENU) || wChar == ' ')
4562 {
4563 if( uItem == NO_SELECTED_ITEM )
4564 MENU_MoveSelection( pwnd, TrackMenu, ITEM_NEXT );
4565 else
4567 }
4568
4569track_menu:
4570 MENU_TrackMenu( TrackMenu, wFlags, 0, 0, pwnd );
4572}
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:3343
#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:3231
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:3144
PMENU WINAPI IntGetMenu(HWND hWnd)
Definition: menu.c:248
#define ITEM_NEXT
Definition: menu.c:93
#define GA_PARENT
Definition: winuser.h:2791
#define VK_RETURN
Definition: winuser.h:2204
#define TPM_LEFTALIGN
Definition: winuser.h:2380
#define TPM_LEFTBUTTON
Definition: winuser.h:2382
#define WM_KEYDOWN
Definition: winuser.h:1718

Referenced by DefWndHandleSysCommand().

◆ MENU_TrackMouseMenuBar()

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

Definition at line 4486 of file menu.c.

4487{
4488 PMENU pMenu = (ht == HTSYSMENU) ? IntGetSystemMenu(pWnd, FALSE) : IntGetMenu( UserHMGetHandle(pWnd) ); // See 74276 and CORE-12801
4490
4491 TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", pWnd, ht, pt.x, pt.y);
4492
4493 if (pWnd->ExStyle & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
4494 if (VerifyMenu(pMenu))
4495 {
4496 /* map point to parent client coordinates */
4499 {
4501 }
4502
4503 MENU_InitTracking(pWnd, pMenu, FALSE, wFlags);
4504 /* fetch the window menu again, it may have changed */
4505 pMenu = (ht == HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pWnd) ) : IntGetMenu( UserHMGetHandle(pWnd) );
4506 MENU_TrackMenu(pMenu, wFlags, pt.x, pt.y, pWnd);
4508 }
4509}
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:1403
PMENU FASTCALL IntGetSystemMenu(PWND Window, BOOL bRevert)
Definition: menu.c:5399
#define TPM_BUTTONDOWN
Definition: menu.c:89
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define TPM_VERTICAL
Definition: winuser.h:2385

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

4653{
4654 PPOPUPMENU pPopupMenu;
4655
4656 *lResult = 0;
4657
4658 TRACE("PMWP : pwnd=%x msg=%d wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
4659
4660 if (Wnd)
4661 {
4662 if (!Wnd->fnid)
4663 {
4664 if (Message != WM_NCCREATE)
4665 {
4666 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4667 return TRUE;
4668 }
4669 Wnd->fnid = FNID_MENU;
4670 pPopupMenu = DesktopHeapAlloc( Wnd->head.rpdesk, sizeof(POPUPMENU) );
4671 if (pPopupMenu == NULL)
4672 {
4673 return TRUE;
4674 }
4675 pPopupMenu->posSelectedItem = NO_SELECTED_ITEM;
4676 pPopupMenu->spwndPopupMenu = Wnd;
4677 ((PMENUWND)Wnd)->ppopupmenu = pPopupMenu;
4678 TRACE("Pop Up Menu is Setup! Msg %d\n",Message);
4679 *lResult = 1;
4680 return TRUE;
4681 }
4682 else
4683 {
4684 if (Wnd->fnid != FNID_MENU)
4685 {
4686 ERR("Wrong window class for Menu! fnid %x\n",Wnd->fnid);
4687 return TRUE;
4688 }
4689 pPopupMenu = ((PMENUWND)Wnd)->ppopupmenu;
4690 }
4691 }
4692
4693 switch(Message)
4694 {
4695 case WM_CREATE:
4696 {
4698 pPopupMenu->spmenu = UserGetMenuObject(cs->lpCreateParams);
4699 if (pPopupMenu->spmenu)
4700 {
4701 UserReferenceObject(pPopupMenu->spmenu);
4702 }
4703 break;
4704 }
4705
4706 case WM_MOUSEACTIVATE: /* We don't want to be activated */
4707 *lResult = MA_NOACTIVATE;
4708 break;
4709
4710 case WM_PAINT:
4711 {
4712 PAINTSTRUCT ps;
4713 IntBeginPaint(Wnd, &ps);
4714 MENU_DrawPopupMenu(Wnd, ps.hdc, pPopupMenu->spmenu);
4715 IntEndPaint(Wnd, &ps);
4716 break;
4717 }
4718
4719 case WM_PRINTCLIENT:
4720 {
4721 MENU_DrawPopupMenu( Wnd, (HDC)wParam, pPopupMenu->spmenu);
4722 break;
4723 }
4724
4725 case WM_ERASEBKGND:
4726 *lResult = 1;
4727 break;
4728
4729 case WM_DESTROY:
4730 /* zero out global pointer in case resident popup window was destroyed. */
4731 if (pPopupMenu)
4732 {
4733 if (UserHMGetHandle(Wnd) == top_popup)
4734 {
4735 top_popup = NULL;
4737 }
4738 }
4739 else
4740 {
4741 ERR("No Window Pop Up!\n");
4742 }
4743 break;
4744
4745 case WM_NCDESTROY:
4746 {
4747 if (pPopupMenu->spmenu)
4748 {
4749 IntReleaseMenuObject(pPopupMenu->spmenu);
4750 }
4751 DesktopHeapFree(Wnd->head.rpdesk, pPopupMenu );
4752 ((PMENUWND)Wnd)->ppopupmenu = 0;
4753 Wnd->fnid = FNID_DESTROY;
4754 break;
4755 }
4756
4757 case MM_SETMENUHANDLE: // wine'isms
4758 case MN_SETHMENU:
4759 {
4761 if (!pmenu)
4762 {
4763 ERR("Bad Menu Handle\n");
4764 break;
4765 }
4766 UserReferenceObject(pmenu);
4767 if (pPopupMenu->spmenu)
4768 {
4769 IntReleaseMenuObject(pPopupMenu->spmenu);
4770 }
4771 pPopupMenu->spmenu = pmenu;
4772 break;
4773 }
4774
4775 case MM_GETMENUHANDLE: // wine'isms
4776 case MN_GETHMENU:
4777 *lResult = (LRESULT)(pPopupMenu ? (pPopupMenu->spmenu ? UserHMGetHandle(pPopupMenu->spmenu) : NULL) : NULL);
4778 break;
4779
4780 default:
4781 if (Message > MN_GETHMENU && Message < MN_GETHMENU+19)
4782 {
4783 ERR("Someone is passing unknown menu messages %d\n",Message);
4784 }
4785 TRACE("PMWP to IDWP %d\n",Message);
4786 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4787 break;
4788 }
4789
4790 return TRUE;
4791}
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:88
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:1441
BOOL FASTCALL IntEndPaint(PWND Wnd, PPAINTSTRUCT Ps)
Definition: painting.c:1538
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:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
#define WM_CREATE
Definition: winuser.h:1611
#define MN_GETHMENU
Definition: winuser.h:1776
#define MA_NOACTIVATE
Definition: winuser.h:2506
#define WM_NCCREATE
Definition: winuser.h:1686
#define WM_MOUSEACTIVATE
Definition: winuser.h:1640
#define WM_NCDESTROY
Definition: winuser.h:1687
#define WM_DESTROY
Definition: winuser.h:1612

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