ReactOS  0.4.14-dev-854-gb9426a3
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 
858  IntCloneMenuItems(Menu, Source);
859 
860  return Menu;
861 }
DWORD_PTR dwMenuData
Definition: ntuser.h:398
HWND hWnd
Definition: ntuser.h:405
HBRUSH hbrBack
Definition: ntuser.h:399
struct _WND * spwndNotify
Definition: ntuser.h:393
BOOL TimeToHide
Definition: ntuser.h:406
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:535
struct tagMENU MENU
ULONG cxTextAlign
Definition: ntuser.h:392
ULONG cyMenu
Definition: ntuser.h:391
smooth NULL
Definition: ftsmooth.c:416
INT iTop
Definition: ntuser.h:400
DWORD dwContextHelpId
Definition: ntuser.h:396
#define NO_SELECTED_ITEM
Definition: ntuser.h:381
ULONG cyMax
Definition: ntuser.h:397
UINT cItems
Definition: ntuser.h:389
struct tagMENU * PMENU
PITEM rgItems
Definition: ntuser.h:394
BOOL FASTCALL IntCloneMenuItems(PMENU Destination, PMENU Source)
Definition: menu.c:771
INT iMaxTop
Definition: ntuser.h:401
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
ULONG fFlags
Definition: ntuser.h:386
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
ULONG cxMenu
Definition: ntuser.h:390
INT iItem
Definition: ntuser.h:387

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 }
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
#define TRUE
Definition: types.h:120
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
Definition: window.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
#define TRACE(s)
Definition: solgame.cpp:4
int Window
Definition: x11stubs.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
int ret
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231
#define MNF_POPUP
Definition: ntuser.h:370
BOOL IntDestroyMenu(PMENU pMenu, BOOL bRecurse)
Definition: menu.c:269
#define MNF_SYSSUBMENU
Definition: ntuser.h:376
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
Definition: object.c:587

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

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

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 }
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
PROCDESKHEAD head
Definition: ntuser.h:385

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

◆ IntGetMenuState()

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

Definition at line 4972 of file menu.c.

4973 {
4974  PMENU MenuObject;
4975  PITEM pItem;
4976 
4977  if (!(MenuObject = UserGetMenuObject(hMenu)))
4978  {
4979  return (UINT)-1;
4980  }
4981 
4982  if (!(pItem = MENU_FindItem( &MenuObject, &uId, uFlags ))) return -1;
4983 
4984  if (pItem->spSubMenu)
4985  {
4986  return (pItem->spSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|MF_POPUP) & 0xff);
4987  }
4988  else
4989  return (pItem->fType | pItem->fState);
4990 }
UINT fState
Definition: ntuser.h:341
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
UINT uFlags
Definition: api.c:59
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
struct tagMENU * spSubMenu
Definition: ntuser.h:343
#define MF_POPUP
Definition: winuser.h:136
unsigned int UINT
Definition: ndis.h:50
UINT fType
Definition: ntuser.h:340

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

◆ IntGetSystemMenu()

PMENU FASTCALL IntGetSystemMenu ( PWND  Window,
BOOL  bRevert 
)

Definition at line 5380 of file menu.c.

5381 {
5382  PMENU Menu;
5383 
5384  if (bRevert)
5385  {
5386  if (Window->SystemMenu)
5387  {
5388  Menu = UserGetMenuObject(Window->SystemMenu);
5389  if (Menu && !(Menu->fFlags & MNF_SYSDESKMN))
5390  {
5391  IntDestroyMenuObject(Menu, TRUE);
5392  Window->SystemMenu = NULL;
5393  }
5394  }
5395  }
5396  else
5397  {
5398  Menu = Window->SystemMenu ? UserGetMenuObject(Window->SystemMenu) : NULL;
5399  if ((!Menu || Menu->fFlags & MNF_SYSDESKMN) && Window->style & WS_SYSMENU)
5400  {
5401  Menu = MENU_GetSystemMenu(Window, NULL);
5402  Window->SystemMenu = Menu ? UserHMGetHandle(Menu) : NULL;
5403  }
5404  }
5405 
5406  if (Window->SystemMenu)
5407  {
5408  HMENU hMenu = IntGetSubMenu( Window->SystemMenu, 0);
5409  /* Store the dummy sysmenu handle to facilitate the refresh */
5410  /* of the close button if the SC_CLOSE item change */
5411  Menu = UserGetMenuObject(hMenu);
5412  if (Menu)
5413  {
5414  Menu->spwndNotify = Window;
5415  Menu->fFlags |= MNF_SYSSUBMENU;
5416  }
5417  return Menu;
5418  }
5419  return NULL;
5420 }
#define TRUE
Definition: types.h:120
struct _WND * spwndNotify
Definition: ntuser.h:393
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
Definition: window.c:28
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
int Window
Definition: x11stubs.h:26
HMENU FASTCALL IntGetSubMenu(HMENU hMenu, int nPos)
Definition: menu.c:4992
#define MNF_SYSDESKMN
Definition: ntuser.h:375
#define MNF_SYSSUBMENU
Definition: ntuser.h:376
ULONG fFlags
Definition: ntuser.h:386
#define WS_SYSMENU
Definition: pedump.c:629
PMENU FASTCALL MENU_GetSystemMenu(PWND Window, PMENU Popup)
Definition: menu.c:5275
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

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 TRUE
Definition: types.h:120
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL FASTCALL IntSetMenuItemInfo(PMENU MenuObject, PITEM MenuItem, PROSMENUITEMINFO lpmii, PUNICODE_STRING lpstr)
Definition: menu.c:1033
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL FASTCALL IntRemoveMenuItem(PMENU pMenu, UINT nPos, UINT wFlags, BOOL bRecurse)
Definition: menu.c:596
int32_t INT
Definition: typedefs.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
ULONG cyMenu
Definition: ntuser.h:391
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE hbmpUnchecked
Definition: ntuser.h:345
HANDLE hbmpChecked
Definition: ntuser.h:344
static LPCSTR lpstr
Definition: font.c:51
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:27
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by MENU_GetSystemMenu(), and UserInsertMenuItem().

◆ IntIsMenu()

BOOL FASTCALL IntIsMenu ( HMENU  )

Definition at line 240 of file menu.c.

241 {
242  if (UserGetMenuObject(Menu)) return TRUE;
243  return FALSE;
244 }
#define TRUE
Definition: types.h:120
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3

◆ 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 }
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
unsigned int UINT
Definition: ndis.h:50
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 5073 of file menu.c.

5080 {
5081  PITEM MenuItem;
5082  BOOL Ret;
5083 
5084  if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5085  {
5087  return( FALSE);
5088  }
5089  if (SetOrGet)
5090  {
5091  Ret = IntSetMenuItemInfo(Menu, MenuItem, ItemInfo, lpstr);
5092  }
5093  else
5094  {
5095  Ret = IntGetMenuItemInfo(Menu, MenuItem, ItemInfo);
5096  }
5097  return( Ret);
5098 }
#define MF_BYCOMMAND
Definition: winuser.h:202
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
BOOL FASTCALL IntSetMenuItemInfo(PMENU MenuObject, PITEM MenuItem, PROSMENUITEMINFO lpmii, PUNICODE_STRING lpstr)
Definition: menu.c:1033
BOOL FASTCALL IntGetMenuItemInfo(PMENU Menu, PITEM MenuItem, PROSMENUITEMINFO lpmii)
Definition: menu.c:962
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937
static LPCSTR lpstr
Definition: font.c:51
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

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 }
Definition: fontsub.cpp:35
#define TRUE
Definition: types.h:120
static __inline PVOID DesktopHeapReAlloc(IN PDESKTOP Desktop, IN PVOID lpMem, IN SIZE_T Bytes)
Definition: desktop.h:248
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
static ATOM item
Definition: dde.c:856
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:239
#define FreeMenuText(Menu, MenuItem)
Definition: menu.c:183

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

◆ IntSetMenu()

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

Definition at line 5456 of file menu.c.

5460 {
5461  PMENU OldMenu, NewMenu = NULL;
5462 
5463  if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
5464  {
5465  ERR("SetMenu: Window is a Child 0x%p!\n",UserHMGetHandle(Wnd));
5467  return FALSE;
5468  }
5469 
5470  *Changed = (UlongToHandle(Wnd->IDMenu) != Menu);
5471  if (! *Changed)
5472  {
5473  return TRUE;
5474  }
5475 
5476  if (Wnd->IDMenu)
5477  {
5478  OldMenu = IntGetMenuObject(UlongToHandle(Wnd->IDMenu));
5479  ASSERT(NULL == OldMenu || OldMenu->hWnd == UserHMGetHandle(Wnd));
5480  }
5481  else
5482  {
5483  OldMenu = NULL;
5484  }
5485 
5486  if (NULL != Menu)
5487  {
5488  NewMenu = IntGetMenuObject(Menu);
5489  if (NULL == NewMenu)
5490  {
5491  if (NULL != OldMenu)
5492  {
5493  IntReleaseMenuObject(OldMenu);
5494  }
5496  return FALSE;
5497  }
5498  if (NULL != NewMenu->hWnd)
5499  {
5500  /* Can't use the same menu for two windows */
5501  if (NULL != OldMenu)
5502  {
5503  IntReleaseMenuObject(OldMenu);
5504  }
5506  return FALSE;
5507  }
5508 
5509  }
5510 
5511  Wnd->IDMenu = (UINT_PTR) Menu;
5512  if (NULL != NewMenu)
5513  {
5514  NewMenu->hWnd = UserHMGetHandle(Wnd);
5515  IntReleaseMenuObject(NewMenu);
5516  }
5517  if (NULL != OldMenu)
5518  {
5519  OldMenu->hWnd = NULL;
5520  IntReleaseMenuObject(OldMenu);
5521  }
5522 
5523  return TRUE;
5524 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
HWND hWnd
Definition: ntuser.h:405
#define TRUE
Definition: types.h:120
#define WS_CHILD
Definition: pedump.c:617
PMENU FASTCALL IntGetMenuObject(HMENU hMenu)
Definition: menu.c:192
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
UINT_PTR IDMenu
Definition: ntuser.h:695
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define UlongToHandle(ul)
Definition: basetsd.h:97
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ERR(fmt,...)
Definition: debug.h:109
#define WS_POPUP
Definition: pedump.c:616
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
DWORD style
Definition: ntuser.h:670

Referenced by IntCreateWindow(), and NtUserSetMenu().

◆ IntSetMenuItemInfo()

BOOL FASTCALL IntSetMenuItemInfo ( PMENU  ,
PITEM  ,
PROSMENUITEMINFO  ,
PUNICODE_STRING   
)

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 MNF_SYSMENU
Definition: ntuser.h:378
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define MFT_STRING
Definition: winuser.h:741
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
BOOL FASTCALL UserSetMenuDefaultItem(PMENU MenuObject, UINT uItem, UINT fByPos)
Definition: menu.c:1274
#define MF_STRING
Definition: winuser.h:138
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
#define MFT_BITMAP
Definition: winuser.h:733
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
#define MENU_ITEM_TYPE(flags)
Definition: menu.c:24
#define MFS_DEFAULT
Definition: winuser.h:743
#define MAXMENUDEPTH
Definition: menu.c:41
#define MIIM_BITMAP
Definition: winuser.h:723
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
int FASTCALL MENU_depth(PMENU pmenu, int depth)
Definition: menu.c:404
uint32_t ULONG_PTR
Definition: typedefs.h:63
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
#define MIIM_SUBMENU
Definition: winuser.h:718
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:230
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define UpdateMenuItemState(state, change)
Definition: menu.c:95
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:669
#define MIIM_ID
Definition: winuser.h:717
#define HBMMENU_CALLBACK
Definition: winuser.h:2605
#define UNICODE_STRING_MAX_CHARS
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HBMMENU_POPUP_MINIMIZE
Definition: winuser.h:2615
#define MFT_SEPARATOR
Definition: winuser.h:739
#define MIIM_TYPE
Definition: winuser.h:720
#define MIIM_CHECKMARKS
Definition: winuser.h:719
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define ERR(fmt,...)
Definition: debug.h:109
#define MIIM_STRING
Definition: winuser.h:722
unsigned short USHORT
Definition: pedump.c:61
#define MFS_HBMMENUBMP
Definition: ntuser.h:336
#define MNF_POPUP
Definition: ntuser.h:370
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static LPCSTR lpstr
Definition: font.c:51
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
static HBITMAP
Definition: button.c:44
#define MFT_OWNERDRAW
Definition: winuser.h:736
#define MIIM_DATA
Definition: winuser.h:721
ULONG fFlags
Definition: ntuser.h:386
PMENU FASTCALL IntCreateMenu(_Out_ PHANDLE Handle, _In_ BOOL IsMenuBar, _In_ PDESKTOP Desktop, _In_ PPROCESSINFO ppi)
Definition: menu.c:729
#define LOWORD(l)
Definition: pedump.c:82
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:45
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define FreeMenuText(Menu, MenuItem)
Definition: menu.c:183
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697

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

4560 {
4561  BOOL ret = FALSE;
4563 
4564  if (pti != pWnd->head.pti)
4565  {
4566  ERR("Must be the same pti!\n");
4567  return ret;
4568  }
4569 
4570  TRACE("hmenu %p flags %04x (%d,%d) hwnd %p lpTpm %p \n", //rect %s\n",
4571  UserHMGetHandle(menu), wFlags, x, y, UserHMGetHandle(pWnd), lpTpm); //,
4572  //lpTpm ? wine_dbgstr_rect( &lpTpm->rcExclude) : "-" );
4573 
4574  if (menu->hWnd && IntIsWindow(menu->hWnd))
4575  {
4577  return FALSE;
4578  }
4579 
4580  if (MENU_InitPopup( pWnd, menu, wFlags ))
4581  {
4582  MENU_InitTracking(pWnd, menu, TRUE, wFlags);
4583 
4584  /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
4585  if (!(wFlags & TPM_NONOTIFY))
4586  {
4588  }
4589 
4590  if (menu->fFlags & MNF_SYSMENU)
4591  MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
4592 
4593  if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y, lpTpm ? &lpTpm->rcExclude : NULL))
4594  ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd);
4595  else
4596  {
4598  pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4599  co_UserSetCapture(NULL); /* release the capture */
4600  }
4601 
4602  MENU_ExitTracking(pWnd, TRUE, wFlags);
4603 
4604  if (menu->hWnd)
4605  {
4606  PWND pwndM = ValidateHwndNoErr( menu->hWnd );
4607  if (pwndM) // wine hack around this with their destroy function.
4608  {
4609  if (!(pWnd->state & WNDS_DESTROYED))
4610  co_UserDestroyWindow( pwndM ); // Fix wrong error return.
4611  }
4612  menu->hWnd = 0;
4613 
4614  if (!(wFlags & TPM_NONOTIFY))
4615  {
4616  co_IntSendMessage( UserHMGetHandle(pWnd), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(menu),
4617  MAKELPARAM(0, IS_SYSTEM_MENU(menu)) );
4618  }
4619  }
4620  }
4621  return ret;
4622 }
#define MNF_SYSMENU
Definition: ntuser.h:378
HWND hWnd
Definition: ntuser.h:405
void FASTCALL MENU_InitSysMenuPopup(PMENU menu, DWORD style, DWORD clsStyle, LONG HitTest)
Definition: menu.c:1362
#define TRUE
Definition: types.h:120
static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
Definition: menu.c:4051
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
static BOOL MENU_InitPopup(PWND pWndOwner, PMENU menu, UINT flags)
Definition: menu.c:2781
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
#define TPM_POPUPMENU
Definition: menu.c:90
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
static BOOL FASTCALL MENU_ShowPopup(PWND pwndOwner, PMENU menu, UINT id, UINT flags, INT x, INT y, const RECT *pExclude)
Definition: menu.c:2939
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
UINT_PTR WPARAM
Definition: windef.h:207
static BOOL FASTCALL MENU_ExitTracking(PWND pWnd, BOOL bPopup, UINT wFlags)
Definition: menu.c:4445
#define HTSYSMENU
Definition: winuser.h:2452
UINT style
Definition: ntuser.h:548
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2648
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
#define QF_CAPTURELOCKED
Definition: msgqueue.h:111
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2552
#define TRACE(s)
Definition: solgame.cpp:4
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1340
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:157
#define TPM_NONOTIFY
Definition: winuser.h:2361
int ret
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1284
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
#define IS_SYSTEM_MENU(MenuInfo)
Definition: menu.c:58
DWORD state
Definition: ntuser.h:665
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4385
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
ULONG fFlags
Definition: ntuser.h:386
RECT rcExclude
Definition: winuser.h:3551
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3547
#define WNDS_DESTROYED
Definition: ntuser.h:604
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
PCLS pcls
Definition: ntuser.h:684
DWORD style
Definition: ntuser.h:670

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;
2745  PMENU lppop = UserGetMenuObject(UlongToHandle(pWnd->IDMenu));
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 }
HFONT ghMenuFont
Definition: menu.c:14
DWORD WINAPI IntDrawMenuBarTemp(PWND pWnd, HDC hDC, LPRECT Rect, PMENU pMenu, HFONT Font)
Definition: menu.c:2685
LONG top
Definition: windef.h:307
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
ULONG cyMenu
Definition: ntuser.h:391
smooth NULL
Definition: ftsmooth.c:416
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
__kernel_entry W32KAPI HFONT APIENTRY NtGdiSelectFont(_In_ HDC hdc, _In_ HFONT hf)
Definition: dcobjs.c:597
UINT_PTR IDMenu
Definition: ntuser.h:695
#define UlongToHandle(ul)
Definition: basetsd.h:97
static HDC hDC
Definition: 3dtext.c:33
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static void MENU_MenuBarCalcSize(HDC hdc, LPRECT lprect, PMENU lppop, PWND pwndOwner)
Definition: menu.c:2101
LONG bottom
Definition: windef.h:309
#define SM_CYMENU
Definition: winuser.h:966

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  {
2668  if (fInsideMenuLoop && top_popup)
2669  {
2671 
2672  if (fInEndMenu)
2673  {
2674  ERR("Already in End loop\n");
2675  return;
2676  }
2677 
2678  fInEndMenu = TRUE;
2680  }
2681  }
2682 }
HWND hWnd
Definition: ntuser.h:405
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1184
#define TRUE
Definition: types.h:120
struct _WND * spwndNotify
Definition: ntuser.h:393
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
smooth NULL
Definition: ftsmooth.c:416
static HMENU top_popup_hmenu
Definition: menu.c:21
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
BOOL fInsideMenuLoop
Definition: menu.c:23
#define WM_CANCELMODE
Definition: winuser.h:1617
static HWND top_popup
Definition: menu.c:20
#define ERR(fmt,...)
Definition: debug.h:109
BOOL fInEndMenu
Definition: menu.c:24

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 }
Definition: fontsub.cpp:35
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
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
#define MF_BYPOSITION
Definition: winuser.h:203
smooth NULL
Definition: ftsmooth.c:416
UINT cItems
Definition: ntuser.h:389
PITEM rgItems
Definition: ntuser.h:394
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50

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);
1372  IntEnableMenuItem( menu, SC_MINIMIZE, (gray ? MF_GRAYED : MF_ENABLED) );
1373  gray = !(style & WS_MAXIMIZEBOX) || (style & WS_MAXIMIZE);
1374  IntEnableMenuItem( menu, SC_MAXIMIZE, (gray ? MF_GRAYED : MF_ENABLED) );
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 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define MF_BYCOMMAND
Definition: winuser.h:202
#define SC_RESTORE
Definition: winuser.h:2573
BOOL FASTCALL UserSetMenuDefaultItem(PMENU MenuObject, UINT uItem, UINT fByPos)
Definition: menu.c:1274
#define CS_NOCLOSE
Definition: winuser.h:649
#define WS_MINIMIZE
Definition: pedump.c:622
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SC_MAXIMIZE
Definition: winuser.h:2563
UINT FASTCALL IntEnableMenuItem(PMENU MenuObject, UINT uIDEnableItem, UINT uEnable)
Definition: menu.c:1217
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define MF_ENABLED
Definition: winuser.h:128
#define SC_MINIMIZE
Definition: winuser.h:2561
#define HTCAPTION
Definition: winuser.h:2451
#define WS_MINIMIZEBOX
Definition: pedump.c:631
#define SC_SIZE
Definition: winuser.h:2559
unsigned int UINT
Definition: ndis.h:50
#define SC_MOVE
Definition: winuser.h:2560
#define SC_CLOSE
Definition: winuser.h:2567
#define MF_GRAYED
Definition: winuser.h:129
Arabic default style
Definition: afstyles.h:93
#define WS_MAXIMIZE
Definition: pedump.c:623

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

◆ MENU_IsMenuActive()

PWND MENU_IsMenuActive ( VOID  )

Definition at line 2650 of file menu.c.

2651 {
2652  return ValidateHwndNoErr(top_popup);
2653 }
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
static HWND top_popup
Definition: menu.c:20

Referenced by IntDefWindowProc().

◆ MENU_TrackKbdMenuBar()

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

Definition at line 4497 of file menu.c.

4498 {
4499  UINT uItem = NO_SELECTED_ITEM;
4500  PMENU TrackMenu;
4502 
4503  TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", UserHMGetHandle(pwnd), wParam, wChar);
4504 
4505  /* find window that has a menu */
4506 
4507  while (!( (pwnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD ) )
4508  if (!(pwnd = UserGetAncestor( pwnd, GA_PARENT ))) return;
4509 
4510  /* check if we have to track a system menu */
4511 
4512  TrackMenu = IntGetMenu( UserHMGetHandle(pwnd) );
4513  if (!TrackMenu || (pwnd->style & WS_MINIMIZE) != 0 || wChar == ' ' )
4514  {
4515  if (!(pwnd->style & WS_SYSMENU)) return;
4516  TrackMenu = get_win_sys_menu( UserHMGetHandle(pwnd) );
4517  uItem = 0;
4518  wParam |= HTSYSMENU; /* prevent item lookup */
4519  }
4520 
4521  if (!VerifyMenu( TrackMenu )) return;
4522 
4523  MENU_InitTracking( pwnd, TrackMenu, FALSE, wFlags );
4524 
4525  /* fetch the window menu again, it may have changed */
4526  TrackMenu = (wParam & HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pwnd) ) : IntGetMenu( UserHMGetHandle(pwnd) );
4527 
4528  if( wChar && wChar != ' ' )
4529  {
4530  uItem = MENU_FindItemByKey( pwnd, TrackMenu, wChar, (wParam & HTSYSMENU) );
4531  if ( uItem >= (UINT)(-2) )
4532  {
4533  if( uItem == (UINT)(-1) ) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0);
4534  /* schedule end of menu tracking */
4535  wFlags |= TF_ENDMENU;
4536  goto track_menu;
4537  }
4538  }
4539 
4540  MENU_SelectItem( pwnd, TrackMenu, uItem, TRUE, 0 );
4541 
4542  if (!(wParam & HTSYSMENU) || wChar == ' ')
4543  {
4544  if( uItem == NO_SELECTED_ITEM )
4545  MENU_MoveSelection( pwnd, TrackMenu, ITEM_NEXT );
4546  else
4548  }
4549 
4550 track_menu:
4551  MENU_TrackMenu( TrackMenu, wFlags, 0, 0, pwnd );
4552  MENU_ExitTracking( pwnd, FALSE, wFlags);
4553 }
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1184
PMENU WINAPI IntGetMenu(HWND hWnd)
Definition: menu.c:248
#define TRUE
Definition: types.h:120
static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
Definition: menu.c:4051
#define TPM_LEFTALIGN
Definition: winuser.h:2352
#define ITEM_NEXT
Definition: menu.c:93
#define WS_CHILD
Definition: pedump.c:617
#define VK_RETURN
Definition: winuser.h:2176
WPARAM wParam
Definition: combotst.c:138
static UINT FASTCALL MENU_FindItemByKey(PWND WndOwner, PMENU menu, WCHAR Key, BOOL ForceMenuChar)
Definition: menu.c:1535
static BOOL FASTCALL MENU_ExitTracking(PWND pWnd, BOOL bPopup, UINT wFlags)
Definition: menu.c:4445
#define HTSYSMENU
Definition: winuser.h:2452
#define WS_MINIMIZE
Definition: pedump.c:622
static void FASTCALL MENU_MoveSelection(PWND pwndOwner, PMENU menu, INT offset)
Definition: menu.c:3226
#define GA_PARENT
Definition: winuser.h:2763
PMENU get_win_sys_menu(HWND hwnd)
Definition: menu.c:258
PMENU FASTCALL VerifyMenu(PMENU pMenu)
Definition: menu.c:201
#define WM_KEYDOWN
Definition: winuser.h:1697
HWND hwndSAS
Definition: winsta.c:24
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
static void FASTCALL MENU_SelectItem(PWND pwndOwner, PMENU menu, UINT wIndex, BOOL sendMenuSelect, PMENU topmenu)
Definition: menu.c:3139
#define TRACE(s)
Definition: solgame.cpp:4
#define NO_SELECTED_ITEM
Definition: ntuser.h:381
#define TF_ENDMENU
Definition: menu.c:33
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
PWND FASTCALL UserGetAncestor(PWND Wnd, UINT Type)
Definition: window.c:3148
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4385
#define TPM_LEFTBUTTON
Definition: winuser.h:2354
#define LN_MESSAGE_BEEP
Definition: undocuser.h:118
#define WS_SYSMENU
Definition: pedump.c:629
DWORD style
Definition: ntuser.h:670

Referenced by DefWndHandleSysCommand().

◆ MENU_TrackMouseMenuBar()

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

Definition at line 4467 of file menu.c.

4468 {
4469  PMENU pMenu = (ht == HTSYSMENU) ? IntGetSystemMenu(pWnd, FALSE) : IntGetMenu( UserHMGetHandle(pWnd) ); // See 74276 and CORE-12801
4471 
4472  TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", pWnd, ht, pt.x, pt.y);
4473 
4474  if (pWnd->ExStyle & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
4475  if (VerifyMenu(pMenu))
4476  {
4477  /* map point to parent client coordinates */
4479  if (Parent != UserGetDesktopWindow())
4480  {
4482  }
4483 
4484  MENU_InitTracking(pWnd, pMenu, FALSE, wFlags);
4485  /* fetch the window menu again, it may have changed */
4486  pMenu = (ht == HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pWnd) ) : IntGetMenu( UserHMGetHandle(pWnd) );
4487  MENU_TrackMenu(pMenu, wFlags, pt.x, pt.y, pWnd);
4488  MENU_ExitTracking(pWnd, FALSE, wFlags);
4489  }
4490 }
#define TPM_VERTICAL
Definition: winuser.h:2357
DWORD ExStyle
Definition: ntuser.h:668
PMENU WINAPI IntGetMenu(HWND hWnd)
Definition: menu.c:248
static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
Definition: menu.c:4051
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2352
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:728
static BOOL FASTCALL MENU_ExitTracking(PWND pWnd, BOOL bPopup, UINT wFlags)
Definition: menu.c:4445
#define HTSYSMENU
Definition: winuser.h:2452
#define GA_PARENT
Definition: winuser.h:2763
PMENU get_win_sys_menu(HWND hwnd)
Definition: menu.c:258
PMENU FASTCALL VerifyMenu(PMENU pMenu)
Definition: menu.c:201
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
PMENU FASTCALL IntGetSystemMenu(PWND Window, BOOL bRevert)
Definition: menu.c:5380
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:212
#define TPM_BUTTONDOWN
Definition: menu.c:89
PWND FASTCALL UserGetAncestor(PWND Wnd, UINT Type)
Definition: window.c:3148
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
Definition: ntuser.h:657
static const struct newhuff ht[]
Definition: huffman.h:296
unsigned int UINT
Definition: ndis.h:50
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4385
#define TPM_LEFTBUTTON
Definition: winuser.h:2354

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");
385  ghMenuFont = NULL;
386  return FALSE;
387  }
388 
391 
392  co_IntSetupOBM();
393  }
394 
395  return TRUE;
396 }
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1252
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1155
#define TRUE
Definition: types.h:120
HFONT ghMenuFont
Definition: menu.c:14
VOID FASTCALL co_IntSetupOBM(VOID)
Definition: callback.c:1169
smooth NULL
Definition: ftsmooth.c:416
HFONT FASTCALL GreCreateFontIndirectW(LOGFONTW *lplf)
Definition: font.c:23
#define ERR(fmt,...)
Definition: debug.h:109
#define FW_BOLD
Definition: wingdi.h:377
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define min(a, b)
Definition: monoChain.cc:55
#define FW_NORMAL
Definition: wingdi.h:372
#define FW_HEAVY
Definition: wingdi.h:380
HFONT ghMenuFontBold
Definition: menu.c:15
BOOL FASTCALL UserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2072

◆ PopupMenuWndProc()

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

Definition at line 4628 of file menu.c.

4634 {
4635  PPOPUPMENU pPopupMenu;
4636 
4637  *lResult = 0;
4638 
4639  TRACE("PMWP : pwnd=%x msg=%d wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
4640 
4641  if (Wnd)
4642  {
4643  if (!Wnd->fnid)
4644  {
4645  if (Message != WM_NCCREATE)
4646  {
4647  *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4648  return TRUE;
4649  }
4650  Wnd->fnid = FNID_MENU;
4651  pPopupMenu = DesktopHeapAlloc( Wnd->head.rpdesk, sizeof(POPUPMENU) );
4652  if (pPopupMenu == NULL)
4653  {
4654  return TRUE;
4655  }
4656  pPopupMenu->posSelectedItem = NO_SELECTED_ITEM;
4657  pPopupMenu->spwndPopupMenu = Wnd;
4658  ((PMENUWND)Wnd)->ppopupmenu = pPopupMenu;
4659  TRACE("Pop Up Menu is Setup! Msg %d\n",Message);
4660  *lResult = 1;
4661  return TRUE;
4662  }
4663  else
4664  {
4665  if (Wnd->fnid != FNID_MENU)
4666  {
4667  ERR("Wrong window class for Menu! fnid %x\n",Wnd->fnid);
4668  return TRUE;
4669  }
4670  pPopupMenu = ((PMENUWND)Wnd)->ppopupmenu;
4671  }
4672  }
4673 
4674  switch(Message)
4675  {
4676  case WM_CREATE:
4677  {
4679  pPopupMenu->spmenu = UserGetMenuObject(cs->lpCreateParams);
4680  if (pPopupMenu->spmenu)
4681  {
4682  UserReferenceObject(pPopupMenu->spmenu);
4683  }
4684  break;
4685  }
4686 
4687  case WM_MOUSEACTIVATE: /* We don't want to be activated */
4688  *lResult = MA_NOACTIVATE;
4689  break;
4690 
4691  case WM_PAINT:
4692  {
4693  PAINTSTRUCT ps;
4694  IntBeginPaint(Wnd, &ps);
4695  MENU_DrawPopupMenu(Wnd, ps.hdc, pPopupMenu->spmenu);
4696  IntEndPaint(Wnd, &ps);
4697  break;
4698  }
4699 
4700  case WM_PRINTCLIENT:
4701  {
4702  MENU_DrawPopupMenu( Wnd, (HDC)wParam, pPopupMenu->spmenu);
4703  break;
4704  }
4705 
4706  case WM_ERASEBKGND:
4707  *lResult = 1;
4708  break;
4709 
4710  case WM_DESTROY:
4711  /* zero out global pointer in case resident popup window was destroyed. */
4712  if (pPopupMenu)
4713  {
4714  if (UserHMGetHandle(Wnd) == top_popup)
4715  {
4716  top_popup = NULL;
4718  }
4719  }
4720  else
4721  {
4722  ERR("No Window Pop Up!\n");
4723  }
4724  break;
4725 
4726  case WM_NCDESTROY:
4727  {
4728  if (pPopupMenu->spmenu)
4729  {
4730  IntReleaseMenuObject(pPopupMenu->spmenu);
4731  }
4732  DesktopHeapFree(Wnd->head.rpdesk, pPopupMenu );
4733  ((PMENUWND)Wnd)->ppopupmenu = 0;
4734  Wnd->fnid = FNID_DESTROY;
4735  break;
4736  }
4737 
4738  case MM_SETMENUHANDLE: // wine'isms
4739  case MN_SETHMENU:
4740  {
4741  PMENU pmenu = UserGetMenuObject((HMENU)wParam);
4742  if (!pmenu)
4743  {
4744  ERR("Bad Menu Handle\n");
4745  break;
4746  }
4747  UserReferenceObject(pmenu);
4748  if (pPopupMenu->spmenu)
4749  {
4750  IntReleaseMenuObject(pPopupMenu->spmenu);
4751  }
4752  pPopupMenu->spmenu = pmenu;
4753  break;
4754  }
4755 
4756  case MM_GETMENUHANDLE: // wine'isms
4757  case MN_GETHMENU:
4758  *lResult = (LRESULT)(pPopupMenu ? (pPopupMenu->spmenu ? UserHMGetHandle(pPopupMenu->spmenu) : NULL) : NULL);
4759  break;
4760 
4761  default:
4762  if (Message > MN_GETHMENU && Message < MN_GETHMENU+19)
4763  {
4764  ERR("Someone is passing unknown menu messages %d\n",Message);
4765  }
4766  TRACE("PMWP to IDWP %d\n",Message);
4767  *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4768  break;
4769  }
4770 
4771  return TRUE;
4772 }
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:532
#define TRUE
Definition: types.h:120
struct _WND * spwndPopupMenu
Definition: ntuser.h:438
struct _DESKTOP * rpdesk
Definition: ntuser.h:189
static void FASTCALL MENU_DrawPopupMenu(PWND wnd, HDC hdc, PMENU menu)
Definition: menu.c:2599
#define FNID_MENU
Definition: ntuser.h:823
static HDC
Definition: imagelist.c:92
#define MN_SETHMENU
Definition: undocuser.h:52
#define FNID_DESTROY
Definition: ntuser.h:859
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
#define WM_PRINTCLIENT
Definition: richedit.h:70
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:3
#define MN_GETHMENU
Definition: winuser.h:1755
uint32_t cs
Definition: isohybrid.c:75
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:230
DWORD fnid
Definition: ntuser.h:673
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
#define WM_MOUSEACTIVATE
Definition: winuser.h:1619
UINT posSelectedItem
Definition: ntuser.h:446
static HMENU top_popup_hmenu
Definition: menu.c:21
#define WM_DESTROY
Definition: winuser.h:1591
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define NO_SELECTED_ITEM
Definition: ntuser.h:381
#define WM_NCDESTROY
Definition: winuser.h:1666
HDC FASTCALL IntBeginPaint(PWND Window, PPAINTSTRUCT Ps)
Definition: painting.c:1422
#define WM_PAINT
Definition: winuser.h:1602
CHAR Message[80]
Definition: alive.c:5
PMENU spmenu
Definition: ntuser.h:441
static HWND top_popup
Definition: menu.c:20
#define LRESULT
Definition: ole.h:14
#define MA_NOACTIVATE
Definition: winuser.h:2478
#define ERR(fmt,...)
Definition: debug.h:109
BOOL FASTCALL IntEndPaint(PWND Wnd, PPAINTSTRUCT Ps)
Definition: painting.c:1518
#define MM_SETMENUHANDLE
Definition: menu.c:28
#define WM_CREATE
Definition: winuser.h:1590
#define MM_GETMENUHANDLE
Definition: menu.c:29
struct _MENUWND * PMENUWND
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:239
#define WM_ERASEBKGND
Definition: winuser.h:1607
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697

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

◆ UserDestroyMenuObject()

BOOLEAN UserDestroyMenuObject ( PVOID  Object)

Definition at line 311 of file menu.c.

312 {
314 }
#define TRUE
Definition: types.h:120
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
static IUnknown Object
Definition: main.c:512