ReactOS 0.4.15-dev-6703-g6528ab8
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:408
struct tagMENU * PMENU
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
ULONG fFlags
Definition: ntuser.h:413
ULONG cyMenu
Definition: ntuser.h:418
struct _WND * spwndNotify
Definition: ntuser.h:420
INT iItem
Definition: ntuser.h:414
UINT cItems
Definition: ntuser.h:416
DWORD dwContextHelpId
Definition: ntuser.h:423
BOOL TimeToHide
Definition: ntuser.h:433
DWORD_PTR dwMenuData
Definition: ntuser.h:425
HWND hWnd
Definition: ntuser.h:432
ULONG cxMenu
Definition: ntuser.h:417
ULONG cyMax
Definition: ntuser.h:424
INT iTop
Definition: ntuser.h:427
INT iMaxTop
Definition: ntuser.h:428
HBRUSH hbrBack
Definition: ntuser.h:426
ULONG cxTextAlign
Definition: ntuser.h:419
PITEM rgItems
Definition: ntuser.h:421
BOOL FASTCALL IntCloneMenuItems(PMENU Destination, PMENU Source)
Definition: menu.c: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
350 ret = UserDeleteObject(Menu->head.h, TYPE_MENU);
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:403
#define MNF_POPUP
Definition: ntuser.h:397
#define ASSERT(a)
Definition: mode.c:44
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:224
#define TRACE(s)
Definition: solgame.cpp:4
Definition: window.c:28
Definition: ntuser.h:689
int ret
BOOL IntDestroyMenu(PMENU pMenu, BOOL bRecurse)
Definition: menu.c: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 5013 of file menu.c.

5014{
5015 PMENU menu, pSubTarget;
5016 UINT Pos;
5017 if (((*hMenu)==(HMENU)0xffff) ||(!(menu = UserGetMenuObject(*hMenu))))
5018 return NO_SELECTED_ITEM;
5019
5020 pSubTarget = UserGetMenuObject(hSubTarget);
5021
5022 Pos = MENU_FindSubMenu(&menu, pSubTarget );
5023
5024 *hMenu = (menu ? UserHMGetHandle(menu) : NULL);
5025
5026 return Pos;
5027}
ush Pos
Definition: deflate.h:92
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c: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:412

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

◆ IntGetMenuState()

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

Definition at line 4973 of file menu.c.

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

5382{
5383 PMENU Menu;
5384
5385 if (bRevert)
5386 {
5387 if (Window->SystemMenu)
5388 {
5389 Menu = UserGetMenuObject(Window->SystemMenu);
5390 if (Menu && !(Menu->fFlags & MNF_SYSDESKMN))
5391 {
5393 Window->SystemMenu = NULL;
5394 }
5395 }
5396 }
5397 else
5398 {
5399 Menu = Window->SystemMenu ? UserGetMenuObject(Window->SystemMenu) : NULL;
5400 if ((!Menu || Menu->fFlags & MNF_SYSDESKMN) && Window->style & WS_SYSMENU)
5401 {
5403 Window->SystemMenu = Menu ? UserHMGetHandle(Menu) : NULL;
5404 }
5405 }
5406
5407 if (Window->SystemMenu)
5408 {
5409 HMENU hMenu = IntGetSubMenu( Window->SystemMenu, 0);
5410 /* Store the dummy sysmenu handle to facilitate the refresh */
5411 /* of the close button if the SC_CLOSE item change */
5412 Menu = UserGetMenuObject(hMenu);
5413 if (Menu)
5414 {
5415 Menu->spwndNotify = Window;
5416 Menu->fFlags |= MNF_SYSSUBMENU;
5417 }
5418 return Menu;
5419 }
5420 return NULL;
5421}
#define MNF_SYSDESKMN
Definition: ntuser.h:402
#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:5276
HMENU FASTCALL IntGetSubMenu(HMENU hMenu, int nPos)
Definition: menu.c:4993

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:371
HANDLE hbmpUnchecked
Definition: ntuser.h:372
int32_t INT
Definition: typedefs.h:58
BOOL FASTCALL IntSetMenuItemInfo(PMENU MenuObject, PITEM MenuItem, PROSMENUITEMINFO lpmii, PUNICODE_STRING lpstr)
Definition: menu.c: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:28
#define MF_BYCOMMAND
Definition: winuser.h:202
#define MF_BYPOSITION
Definition: winuser.h:203
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by MENU_GetSystemMenu(), and UserInsertMenuItem().

◆ IntIsMenu()

BOOL FASTCALL IntIsMenu ( HMENU  Menu)

Definition at line 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 5074 of file menu.c.

5081{
5082 PITEM MenuItem;
5083 BOOL Ret;
5084
5085 if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5086 {
5088 return( FALSE);
5089 }
5090 if (SetOrGet)
5091 {
5092 Ret = IntSetMenuItemInfo(Menu, MenuItem, ItemInfo, lpstr);
5093 }
5094 else
5095 {
5096 Ret = IntGetMenuItemInfo(Menu, MenuItem, ItemInfo);
5097 }
5098 return( Ret);
5099}
_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 5457 of file menu.c.

5461{
5462 PMENU OldMenu, NewMenu = NULL;
5463
5464 if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
5465 {
5466 ERR("SetMenu: Window is a Child 0x%p!\n",UserHMGetHandle(Wnd));
5468 return FALSE;
5469 }
5470
5471 *Changed = (UlongToHandle(Wnd->IDMenu) != Menu);
5472 if (! *Changed)
5473 {
5474 return TRUE;
5475 }
5476
5477 if (Wnd->IDMenu)
5478 {
5479 OldMenu = IntGetMenuObject(UlongToHandle(Wnd->IDMenu));
5480 ASSERT(NULL == OldMenu || OldMenu->hWnd == UserHMGetHandle(Wnd));
5481 }
5482 else
5483 {
5484 OldMenu = NULL;
5485 }
5486
5487 if (NULL != Menu)
5488 {
5489 NewMenu = IntGetMenuObject(Menu);
5490 if (NULL == NewMenu)
5491 {
5492 if (NULL != OldMenu)
5493 {
5494 IntReleaseMenuObject(OldMenu);
5495 }
5497 return FALSE;
5498 }
5499 if (NULL != NewMenu->hWnd)
5500 {
5501 /* Can't use the same menu for two windows */
5502 if (NULL != OldMenu)
5503 {
5504 IntReleaseMenuObject(OldMenu);
5505 }
5507 return FALSE;
5508 }
5509
5510 }
5511
5512 Wnd->IDMenu = (UINT_PTR) Menu;
5513 if (NULL != NewMenu)
5514 {
5515 NewMenu->hWnd = UserHMGetHandle(Wnd);
5516 IntReleaseMenuObject(NewMenu);
5517 }
5518 if (NULL != OldMenu)
5519 {
5520 OldMenu->hWnd = NULL;
5521 IntReleaseMenuObject(OldMenu);
5522 }
5523
5524 return TRUE;
5525}
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define IntReleaseMenuObject(MenuObj)
Definition: menu.h:130
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WS_CHILD
Definition: pedump.c:617
#define WS_POPUP
Definition: pedump.c:616
DWORD style
Definition: ntuser.h:701
UINT_PTR IDMenu
Definition: ntuser.h:726
PMENU FASTCALL IntGetMenuObject(HMENU hMenu)
Definition: menu.c: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:405
#define MFS_HBMMENUBMP
Definition: ntuser.h:363
#define MENU_ITEM_TYPE(flags)
Definition: menu.h:6
static HBITMAP
Definition: button.c:44
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_STRING_MAX_CHARS
#define LOWORD(l)
Definition: pedump.c:82
unsigned short USHORT
Definition: pedump.c:61
struct _DESKTOP * rpdesk
Definition: ntuser.h:219
DWORD_PTR hTaskWow
Definition: ntuser.h:218
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:383
INT cyBmp
Definition: ntuser.h:385
ULONG yItem
Definition: ntuser.h:377
DWORD_PTR dwItemData
Definition: ntuser.h:375
UINT wID
Definition: ntuser.h:369
ULONG dxTab
Definition: ntuser.h:380
UNICODE_STRING lpstr
Definition: ntuser.h:387
USHORT * Xlpstr
Definition: ntuser.h:373
ULONG xItem
Definition: ntuser.h:376
INT cxBmp
Definition: ntuser.h:384
ULONG cxItem
Definition: ntuser.h:378
ULONG cyItem
Definition: ntuser.h:379
ULONG cch
Definition: ntuser.h:374
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HBITMAP hbmpItem
Definition: menu.h:114
HBITMAP hbmpUnchecked
Definition: menu.h:110
SIZE maxBmpSize
Definition: menu.h:119
HMENU hSubMenu
Definition: menu.h:108
LPWSTR dwTypeData
Definition: menu.h:112
LPWSTR lpstr
Definition: menu.h:118
HBITMAP hbmpChecked
Definition: menu.h:109
DWORD dwItemData
Definition: menu.h:111
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:37
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
#define MAXMENUDEPTH
Definition: menu.c:43
BOOL FASTCALL UserSetMenuDefaultItem(PMENU MenuObject, UINT uItem, UINT fByPos)
Definition: menu.c: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:722
#define MIIM_ID
Definition: winuser.h:717
#define HBMMENU_POPUP_MINIMIZE
Definition: winuser.h:2630
#define MIIM_CHECKMARKS
Definition: winuser.h:719
#define MF_STRING
Definition: winuser.h:138
#define MIIM_FTYPE
Definition: winuser.h:724
#define MFT_SEPARATOR
Definition: winuser.h:739
#define MIIM_STATE
Definition: winuser.h:716
#define MFS_DEFAULT
Definition: winuser.h:743
#define MFT_OWNERDRAW
Definition: winuser.h:736
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MIIM_BITMAP
Definition: winuser.h:723
#define MFT_BITMAP
Definition: winuser.h:733
#define MFT_STRING
Definition: winuser.h:741
#define HBMMENU_CALLBACK
Definition: winuser.h:2620
#define MIIM_DATA
Definition: winuser.h:721
#define MIIM_TYPE
Definition: winuser.h:720
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3287
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

◆ IntTrackPopupMenuEx()

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

Definition at line 4559 of file menu.c.

4561{
4562 BOOL ret = FALSE;
4564
4565 if (pti != pWnd->head.pti)
4566 {
4567 ERR("Must be the same pti!\n");
4568 return ret;
4569 }
4570
4571 TRACE("hmenu %p flags %04x (%d,%d) hwnd %p lpTpm %p \n", //rect %s\n",
4572 UserHMGetHandle(menu), wFlags, x, y, UserHMGetHandle(pWnd), lpTpm); //,
4573 //lpTpm ? wine_dbgstr_rect( &lpTpm->rcExclude) : "-" );
4574
4575 if (menu->hWnd && IntIsWindow(menu->hWnd))
4576 {
4578 return FALSE;
4579 }
4580
4581 if (MENU_InitPopup( pWnd, menu, wFlags ))
4582 {
4583 MENU_InitTracking(pWnd, menu, TRUE, wFlags);
4584
4585 /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
4586 if (!(wFlags & TPM_NONOTIFY))
4587 {
4589 }
4590
4591 if (menu->fFlags & MNF_SYSMENU)
4592 MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
4593
4594 if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y, lpTpm ? &lpTpm->rcExclude : NULL))
4595 ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd);
4596 else
4597 {
4599 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4600 co_UserSetCapture(NULL); /* release the capture */
4601 }
4602
4604
4605 if (menu->hWnd)
4606 {
4607 PWND pwndM = ValidateHwndNoErr( menu->hWnd );
4608 if (pwndM) // wine hack around this with their destroy function.
4609 {
4610 if (!(pWnd->state & WNDS_DESTROYED))
4611 co_UserDestroyWindow( pwndM ); // Fix wrong error return.
4612 }
4613 menu->hWnd = 0;
4614
4615 if (!(wFlags & TPM_NONOTIFY))
4616 {
4617 co_IntSendMessage( UserHMGetHandle(pWnd), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(menu),
4618 MAKELPARAM(0, IS_SYSTEM_MENU(menu) ? MF_SYSMENU : 0));
4619 }
4620 }
4621 }
4622 return ret;
4623}
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1458
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define WNDS_DESTROYED
Definition: ntuser.h:631
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3707
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2553
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
UINT style
Definition: ntuser.h:575
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
PCLS pcls
Definition: ntuser.h:715
THRDESKHEAD head
Definition: ntuser.h:690
DWORD state
Definition: ntuser.h:696
RECT rcExclude
Definition: winuser.h:3566
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c: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:4446
#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:4052
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4386
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:3998
#define MF_SYSMENU
Definition: winuser.h:141
#define TPM_NONOTIFY
Definition: winuser.h:2376
#define WM_INITMENUPOPUP
Definition: winuser.h:1736
#define HTSYSMENU
Definition: winuser.h:2467

Referenced by IntDefWindowProc(), and NtUserTrackPopupMenuEx().

◆ MENU_DrawMenuBar()

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

Definition at line 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:208
#define SM_CYMENU
Definition: winuser.h:970

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

◆ MENU_EndMenu()

void MENU_EndMenu ( PWND  pwnd)

Definition at line 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:1625

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) != 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:2466
#define SC_SIZE
Definition: winuser.h:2574
#define SC_MINIMIZE
Definition: winuser.h:2576
#define MF_ENABLED
Definition: winuser.h:128
#define SC_CLOSE
Definition: winuser.h:2582
#define SC_MOVE
Definition: winuser.h:2575
#define SC_RESTORE
Definition: winuser.h:2588
#define CS_NOCLOSE
Definition: winuser.h:649
#define SC_MAXIMIZE
Definition: winuser.h:2578
#define MF_GRAYED
Definition: winuser.h:129

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

◆ MENU_IsMenuActive()

PWND MENU_IsMenuActive ( VOID  )

Definition at line 2650 of file menu.c.

2651{
2653}

Referenced by IntDefWindowProc().

◆ MENU_TrackKbdMenuBar()

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

Definition at line 4498 of file menu.c.

4499{
4500 UINT uItem = NO_SELECTED_ITEM;
4501 PMENU TrackMenu;
4503
4504 TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", UserHMGetHandle(pwnd), wParam, wChar);
4505
4506 /* find window that has a menu */
4507
4508 while (!( (pwnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD ) )
4509 if (!(pwnd = UserGetAncestor( pwnd, GA_PARENT ))) return;
4510
4511 /* check if we have to track a system menu */
4512
4513 TrackMenu = IntGetMenu( UserHMGetHandle(pwnd) );
4514 if (!TrackMenu || (pwnd->style & WS_MINIMIZE) != 0 || wChar == ' ' )
4515 {
4516 if (!(pwnd->style & WS_SYSMENU)) return;
4517 TrackMenu = get_win_sys_menu( UserHMGetHandle(pwnd) );
4518 uItem = 0;
4519 wParam |= HTSYSMENU; /* prevent item lookup */
4520 }
4521
4522 if (!VerifyMenu( TrackMenu )) return;
4523
4524 MENU_InitTracking( pwnd, TrackMenu, FALSE, wFlags );
4525
4526 /* fetch the window menu again, it may have changed */
4527 TrackMenu = (wParam & HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pwnd) ) : IntGetMenu( UserHMGetHandle(pwnd) );
4528
4529 if( wChar && wChar != ' ' )
4530 {
4531 uItem = MENU_FindItemByKey( pwnd, TrackMenu, wChar, (wParam & HTSYSMENU) );
4532 if ( uItem >= (UINT)(-2) )
4533 {
4534 if( uItem == (UINT)(-1) ) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0);
4535 /* schedule end of menu tracking */
4536 wFlags |= TF_ENDMENU;
4537 goto track_menu;
4538 }
4539 }
4540
4541 MENU_SelectItem( pwnd, TrackMenu, uItem, TRUE, 0 );
4542
4543 if (!(wParam & HTSYSMENU) || wChar == ' ')
4544 {
4545 if( uItem == NO_SELECTED_ITEM )
4546 MENU_MoveSelection( pwnd, TrackMenu, ITEM_NEXT );
4547 else
4549 }
4550
4551track_menu:
4552 MENU_TrackMenu( TrackMenu, wFlags, 0, 0, pwnd );
4554}
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:3349
#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:2778
#define VK_RETURN
Definition: winuser.h:2191
#define TPM_LEFTALIGN
Definition: winuser.h:2367
#define TPM_LEFTBUTTON
Definition: winuser.h:2369
#define WM_KEYDOWN
Definition: winuser.h:1705

Referenced by DefWndHandleSysCommand().

◆ MENU_TrackMouseMenuBar()

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

Definition at line 4468 of file menu.c.

4469{
4470 PMENU pMenu = (ht == HTSYSMENU) ? IntGetSystemMenu(pWnd, FALSE) : IntGetMenu( UserHMGetHandle(pWnd) ); // See 74276 and CORE-12801
4472
4473 TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", pWnd, ht, pt.x, pt.y);
4474
4475 if (pWnd->ExStyle & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
4476 if (VerifyMenu(pMenu))
4477 {
4478 /* map point to parent client coordinates */
4481 {
4483 }
4484
4485 MENU_InitTracking(pWnd, pMenu, FALSE, wFlags);
4486 /* fetch the window menu again, it may have changed */
4487 pMenu = (ht == HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pWnd) ) : IntGetMenu( UserHMGetHandle(pWnd) );
4488 MENU_TrackMenu(pMenu, wFlags, pt.x, pt.y, pWnd);
4490 }
4491}
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:699
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
PMENU FASTCALL IntGetSystemMenu(PWND Window, BOOL bRevert)
Definition: menu.c:5381
#define TPM_BUTTONDOWN
Definition: menu.c:89
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define TPM_VERTICAL
Definition: winuser.h:2372

Referenced by DefWndHandleSysCommand().

◆ MenuInit()

BOOL MenuInit ( VOID  )

Definition at line 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:2104
#define FW_BOLD
Definition: wingdi.h:378
#define FW_NORMAL
Definition: wingdi.h:373
#define FW_HEAVY
Definition: wingdi.h:381

◆ PopupMenuWndProc()

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

Definition at line 4629 of file menu.c.

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

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

◆ UserDestroyMenuObject()

BOOLEAN UserDestroyMenuObject ( PVOID  Object)

Definition at line 311 of file menu.c.

312{
314}
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object