ReactOS 0.4.16-dev-1470-gfbd70c8
menu.c File Reference
#include <win32k.h>
Include dependency graph for menu.c:

Go to the source code of this file.

Classes

struct  MTRACKER
 

Macros

#define MM_SETMENUHANDLE   (WM_USER + 0)
 
#define MM_GETMENUHANDLE   (WM_USER + 1)
 
#define TF_ENDMENU   0x10000
 
#define TF_SUSPENDPOPUP   0x20000
 
#define TF_SKIPREMOVE   0x40000
 
#define MAXMENUDEPTH   30
 
#define MNS_STYLE_MASK   (MNS_NOCHECK|MNS_MODELESS|MNS_DRAGDROP|MNS_AUTODISMISS|MNS_NOTIFYBYPOS|MNS_CHECKORBMP)
 
#define MENUITEMINFO_TYPE_MASK
 
#define TYPE_MASK   (MENUITEMINFO_TYPE_MASK | MF_POPUP | MF_SYSMENU)
 
#define STATE_MASK   (~TYPE_MASK)
 
#define MENUITEMINFO_STATE_MASK   (STATE_MASK & ~(MF_BYPOSITION | MF_MOUSESELECT))
 
#define MII_STATE_MASK   (MFS_GRAYED|MFS_CHECKED|MFS_HILITE|MFS_DEFAULT)
 
#define IS_SYSTEM_MENU(MenuInfo)    (!!((MenuInfo)->fFlags & MNF_SYSMENU))
 
#define IS_MAGIC_BITMAP(id)   ((id) && ((INT_PTR)(id) < 12) && ((INT_PTR)(id) >= -1))
 
#define IS_STRING_ITEM(flags)   (MF_STRING == MENU_ITEM_TYPE(flags))
 
#define MAX_MENU_ITEMS   (0x4000)
 
#define MAX_GOINTOSUBMENU   (0x10)
 
#define MENU_COL_SPACE   4
 
#define MENU_ITEM_HBMP_SPACE   (5)
 
#define MENU_BAR_ITEMS_SPACE   (12)
 
#define SEPARATOR_HEIGHT   (5)
 
#define MENU_TAB_SPACE   (8)
 
#define TPM_INTERNAL   0xF0000000
 
#define TPM_BUTTONDOWN   0x40000000 /* menu was clicked before tracking */
 
#define TPM_POPUPMENU   0x20000000 /* menu is a popup menu */
 
#define ITEM_PREV   -1
 
#define ITEM_NEXT   1
 
#define UpdateMenuItemState(state, change)
 
#define FreeMenuText(Menu, MenuItem)
 
#define SHOW_DEBUGRECT   0
 
#define VALID_TPM_FLAGS
 

Functions

 DBG_DEFAULT_CHANNEL (UserMenu)
 
BOOL FASTCALL UITOOLS95_DrawFrameMenu (HDC dc, LPRECT r, UINT uFlags)
 
PMENU FASTCALL IntGetMenuObject (HMENU hMenu)
 
PMENU FASTCALL VerifyMenu (PMENU pMenu)
 
BOOL FASTCALL IntIsMenu (HMENU Menu)
 
PMENU WINAPI IntGetMenu (HWND hWnd)
 
PMENU get_win_sys_menu (HWND hwnd)
 
BOOL IntDestroyMenu (PMENU pMenu, BOOL bRecurse)
 
BOOLEAN UserDestroyMenuObject (PVOID Object)
 
BOOL FASTCALL IntDestroyMenuObject (PMENU Menu, BOOL bRecurse)
 
BOOL MenuInit (VOID)
 
int FASTCALL MENU_depth (PMENU pmenu, int depth)
 
static UINT MENU_GetStartOfNextColumn (PMENU menu)
 
static UINT MENU_GetStartOfPrevColumn (PMENU menu)
 
PITEM FASTCALL MENU_FindItem (PMENU *pmenu, UINT *nPos, UINT wFlags)
 
static UINT FASTCALL MENU_FindSubMenu (PMENU *menu, PMENU SubTarget)
 
BOOL FASTCALL IntRemoveMenuItem (PMENU pMenu, UINT nPos, UINT wFlags, BOOL bRecurse)
 
ITEMMENU_InsertItem (PMENU menu, UINT pos, UINT flags, PMENU *submenu, UINT *npos)
 
BOOL FASTCALL IntInsertMenuItem (_In_ PMENU MenuObject, UINT uItem, BOOL fByPosition, PROSMENUITEMINFO ItemInfo, PUNICODE_STRING lpstr)
 
PMENU FASTCALL IntCreateMenu (_Out_ PHANDLE Handle, _In_ BOOL IsMenuBar, _In_ PDESKTOP Desktop, _In_ PPROCESSINFO ppi)
 
BOOL FASTCALL IntCloneMenuItems (PMENU Destination, PMENU Source)
 
PMENU FASTCALL IntCloneMenu (PMENU Source)
 
BOOL FASTCALL IntSetMenuFlagRtoL (PMENU Menu)
 
BOOL FASTCALL IntSetMenuContextHelpId (PMENU Menu, DWORD dwContextHelpId)
 
BOOL FASTCALL IntGetMenuInfo (PMENU Menu, PROSMENUINFO lpmi)
 
BOOL FASTCALL IntSetMenuInfo (PMENU Menu, PROSMENUINFO lpmi)
 
BOOL FASTCALL IntGetMenuItemInfo (PMENU Menu, PITEM MenuItem, PROSMENUITEMINFO lpmii)
 
BOOL FASTCALL IntSetMenuItemInfo (PMENU MenuObject, PITEM MenuItem, PROSMENUITEMINFO lpmii, PUNICODE_STRING lpstr)
 
UINT FASTCALL IntEnableMenuItem (PMENU MenuObject, UINT uIDEnableItem, UINT uEnable)
 
DWORD FASTCALL IntCheckMenuItem (PMENU MenuObject, UINT uIDCheckItem, UINT uCheck)
 
BOOL FASTCALL UserSetMenuDefaultItem (PMENU MenuObject, UINT uItem, UINT fByPos)
 
UINT FASTCALL IntGetMenuDefaultItem (PMENU MenuObject, UINT fByPos, UINT gmdiFlags, DWORD *gismc)
 
PMENU FASTCALL co_IntGetSubMenu (PMENU pMenu, int nPos)
 
void FASTCALL MENU_InitSysMenuPopup (PMENU menu, DWORD style, DWORD clsStyle, LONG HitTest)
 
static void FASTCALL MENU_DrawPopupGlyph (HDC dc, LPRECT r, INT_PTR popupMagic, BOOL inactive, BOOL hilite)
 
VOID FASTCALL MENU_AdjustMenuItemRect (PMENU menu, PRECTL rect)
 
static ITEMMENU_FindItemByCoords (MENU *menu, POINT pt, UINT *pos)
 
INT FASTCALL IntMenuItemFromPoint (PWND pWnd, HMENU hMenu, POINT ptScreen)
 
static UINT FASTCALL MENU_FindItemByKey (PWND WndOwner, PMENU menu, WCHAR Key, BOOL ForceMenuChar)
 
static void FASTCALL MENU_GetBitmapItemSize (PITEM lpitem, SIZE *size, PWND WndOwner)
 
static void FASTCALL MENU_DrawBitmapItem (HDC hdc, PITEM lpitem, const RECT *rect, PMENU Menu, PWND WndOwner, UINT odaction, BOOL MenuBar)
 
LONG IntGetDialogBaseUnits (VOID)
 
static void FASTCALL MENU_CalcItemSize (HDC hdc, PITEM lpitem, PMENU Menu, PWND pwndOwner, INT orgX, INT orgY, BOOL menuBar, BOOL textandbmp)
 
static UINT MENU_GetMaxPopupHeight (PMENU lppop)
 
static void FASTCALL MENU_PopupMenuCalcSize (PMENU Menu, PWND WndOwner)
 
static void MENU_MenuBarCalcSize (HDC hdc, LPRECT lprect, PMENU lppop, PWND pwndOwner)
 
static void MENU_DrawScrollArrows (PMENU lppop, HDC hdc)
 
static void FASTCALL MENU_DrawMenuItem (PWND Wnd, PMENU Menu, PWND WndOwner, HDC hdc, PITEM lpitem, UINT Height, BOOL menuBar, UINT odaction)
 
static void FASTCALL MENU_DrawPopupMenu (PWND wnd, HDC hdc, PMENU menu)
 
PWND MENU_IsMenuActive (VOID)
 
void MENU_EndMenu (PWND pwnd)
 
DWORD WINAPI IntDrawMenuBarTemp (PWND pWnd, HDC hDC, LPRECT Rect, PMENU pMenu, HFONT Font)
 
UINT MENU_DrawMenuBar (HDC hDC, LPRECT lprect, PWND pWnd, BOOL suppress_draw)
 
static BOOL MENU_InitPopup (PWND pWndOwner, PMENU menu, UINT flags)
 
static BOOL RECTL_Intersect (const RECT *pRect, INT x, INT y, UINT width, UINT height)
 
static BOOL MENU_MoveRect (UINT flags, INT *x, INT *y, INT width, INT height, const RECT *pExclude, PMONITOR monitor)
 
static BOOL FASTCALL MENU_ShowPopup (PWND pwndOwner, PMENU menu, UINT id, UINT flags, INT x, INT y, const RECT *pExclude)
 
void MENU_EnsureMenuItemVisible (PMENU lppop, UINT wIndex, HDC hdc)
 
static void FASTCALL MENU_SelectItem (PWND pwndOwner, PMENU menu, UINT wIndex, BOOL sendMenuSelect, PMENU topmenu)
 
static void FASTCALL MENU_MoveSelection (PWND pwndOwner, PMENU menu, INT offset)
 
static void FASTCALL MENU_HideSubPopups (PWND pWndOwner, PMENU Menu, BOOL SendMenuSelect, UINT wFlags)
 
static PMENU FASTCALL MENU_ShowSubPopup (PWND WndOwner, PMENU Menu, BOOL SelectFirst, UINT Flags)
 
static INT FASTCALL MENU_ExecFocusedItem (MTRACKER *pmt, PMENU Menu, UINT Flags)
 
static void FASTCALL MENU_SwitchTracking (MTRACKER *pmt, PMENU PtMenu, UINT Index, UINT wFlags)
 
static BOOL FASTCALL MENU_ButtonDown (MTRACKER *pmt, PMENU PtMenu, UINT Flags)
 
static INT FASTCALL MENU_ButtonUp (MTRACKER *pmt, PMENU PtMenu, UINT Flags)
 
static PMENU FASTCALL MENU_PtMenu (PMENU menu, POINT pt)
 
static BOOL FASTCALL MENU_MouseMove (MTRACKER *pmt, PMENU PtMenu, UINT Flags)
 
static PMENU MENU_GetSubPopup (PMENU menu)
 
static LRESULT FASTCALL MENU_DoNextMenu (MTRACKER *pmt, UINT Vk, UINT wFlags)
 
static BOOL FASTCALL MENU_SuspendPopup (MTRACKER *pmt, UINT uMsg)
 
static BOOL FASTCALL MENU_KeyEscape (MTRACKER *pmt, UINT Flags)
 
static void FASTCALL MENU_KeyLeft (MTRACKER *pmt, UINT Flags, UINT msg)
 
static void FASTCALL MENU_KeyRight (MTRACKER *pmt, UINT Flags, UINT msg)
 
static INT FASTCALL MENU_TrackMenu (PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
 
static BOOL FASTCALL MENU_InitTracking (PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
 
static BOOL FASTCALL MENU_ExitTracking (PWND pWnd, BOOL bPopup, UINT wFlags)
 
VOID MENU_TrackMouseMenuBar (PWND pWnd, ULONG ht, POINT pt)
 
VOID MENU_TrackKbdMenuBar (PWND pwnd, UINT wParam, WCHAR wChar)
 
BOOL FASTCALL IntTrackPopupMenuEx (_Inout_ PMENU menu, _In_ UINT wFlags, _In_ INT x, _In_ INT y, _In_ PWND pWnd, _In_opt_ const TPMPARAMS *lpTpm)
 
BOOL WINAPI PopupMenuWndProc (PWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
 
BOOL FASTCALL IntHiliteMenuItem (PWND WindowObject, PMENU MenuObject, UINT uItemHilite, UINT uHilite)
 
BOOLEAN APIENTRY intGetTitleBarInfo (PWND pWindowObject, PTITLEBARINFO bti)
 
DWORD FASTCALL UserInsertMenuItem (PMENU Menu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW UnsafeItemInfo, PUNICODE_STRING lpstr)
 
UINT FASTCALL IntGetMenuState (HMENU hMenu, UINT uId, UINT uFlags)
 
HMENU FASTCALL IntGetSubMenu (HMENU hMenu, int nPos)
 
UINT FASTCALL IntFindSubMenu (HMENU *hMenu, HMENU hSubTarget)
 
HMENU FASTCALL UserCreateMenu (PDESKTOP Desktop, BOOL PopupMenu)
 
BOOL FASTCALL IntMenuItemInfo (PMENU Menu, UINT Item, BOOL ByPosition, PROSMENUITEMINFO ItemInfo, BOOL SetOrGet, PUNICODE_STRING lpstr)
 
BOOL FASTCALL UserMenuItemInfo (PMENU Menu, UINT Item, BOOL ByPosition, PROSMENUITEMINFO UnsafeItemInfo, BOOL SetOrGet, PUNICODE_STRING lpstr)
 
BOOL FASTCALL UserMenuInfo (PMENU Menu, PROSMENUINFO UnsafeMenuInfo, BOOL SetOrGet)
 
BOOL FASTCALL IntGetMenuItemRect (PWND pWnd, PMENU Menu, UINT uItem, PRECTL Rect)
 
PMENU FASTCALL MENU_GetSystemMenu (PWND Window, PMENU Popup)
 
PMENU FASTCALL IntGetSystemMenu (PWND Window, BOOL bRevert)
 
BOOL FASTCALL IntSetSystemMenu (PWND Window, PMENU Menu)
 
BOOL FASTCALL IntSetMenu (PWND Wnd, HMENU Menu, BOOL *Changed)
 
DWORD APIENTRY NtUserCalcMenuBar (HWND hwnd, DWORD leftBorder, DWORD rightBorder, DWORD top, LPRECT prc)
 
DWORD APIENTRY NtUserCheckMenuItem (HMENU hMenu, UINT uIDCheckItem, UINT uCheck)
 
BOOL APIENTRY NtUserDeleteMenu (HMENU hMenu, UINT uPosition, UINT uFlags)
 
HMENU APIENTRY NtUserGetSystemMenu (HWND hWnd, BOOL bRevert)
 
BOOL APIENTRY NtUserSetSystemMenu (HWND hWnd, HMENU hMenu)
 
BOOLEAN APIENTRY NtUserGetTitleBarInfo (HWND hwnd, PTITLEBARINFO bti)
 
BOOL FASTCALL UserDestroyMenu (HMENU hMenu)
 
BOOL APIENTRY NtUserDestroyMenu (HMENU hMenu)
 
UINT APIENTRY NtUserEnableMenuItem (HMENU hMenu, UINT uIDEnableItem, UINT uEnable)
 
BOOL APIENTRY NtUserEndMenu (VOID)
 
BOOL APIENTRY NtUserGetMenuBarInfo (HWND hwnd, LONG idObject, LONG idItem, PMENUBARINFO pmbi)
 
UINT APIENTRY NtUserGetMenuIndex (HMENU hMenu, HMENU hSubMenu)
 
BOOL APIENTRY NtUserGetMenuItemRect (HWND hWnd, HMENU hMenu, UINT uItem, PRECTL lprcItem)
 
BOOL APIENTRY NtUserHiliteMenuItem (HWND hWnd, HMENU hMenu, UINT uItemHilite, UINT uHilite)
 
DWORD APIENTRY NtUserDrawMenuBarTemp (HWND hWnd, HDC hDC, PRECT pRect, HMENU hMenu, HFONT hFont)
 
int APIENTRY NtUserMenuItemFromPoint (HWND hWnd, HMENU hMenu, DWORD X, DWORD Y)
 
DWORD APIENTRY NtUserPaintMenuBar (HWND hWnd, HDC hDC, ULONG leftBorder, ULONG rightBorder, ULONG top, BOOL bActive)
 
BOOL APIENTRY NtUserRemoveMenu (HMENU hMenu, UINT uPosition, UINT uFlags)
 
BOOL APIENTRY NtUserSetMenu (HWND hWnd, HMENU Menu, BOOL Repaint)
 
BOOL APIENTRY NtUserSetMenuContextHelpId (HMENU hMenu, DWORD dwContextHelpId)
 
BOOL APIENTRY NtUserSetMenuDefaultItem (HMENU hMenu, UINT uItem, UINT fByPos)
 
BOOL APIENTRY NtUserSetMenuFlagRtoL (HMENU hMenu)
 
BOOL APIENTRY NtUserThunkedMenuInfo (HMENU hMenu, LPCMENUINFO lpcmi)
 
BOOL APIENTRY NtUserThunkedMenuItemInfo (HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
 
BOOL NTAPI NtUserTrackPopupMenuEx (_In_ HMENU hMenu, _In_ UINT fuFlags, _In_ INT x, _In_ INT y, _In_ HWND hWnd, _In_opt_ LPTPMPARAMS lptpm)
 

Variables

HFONT ghMenuFont = NULL
 
HFONT ghMenuFontBold = NULL
 
static SIZE MenuCharSize
 
static HWND top_popup = NULL
 
static HMENU top_popup_hmenu = NULL
 
BOOL fInsideMenuLoop = FALSE
 
BOOL fInEndMenu = FALSE
 

Macro Definition Documentation

◆ FreeMenuText

#define FreeMenuText (   Menu,
  MenuItem 
)
Value:
{ \
if((MENU_ITEM_TYPE((MenuItem)->fType) == MF_STRING) && \
(MenuItem)->lpstr.Length) { \
DesktopHeapFree(((PMENU)Menu)->head.rpdesk, (MenuItem)->lpstr.Buffer); \
} \
}
struct outqueuenode * head
Definition: adnsresfilter.c:66
#define MENU_ITEM_TYPE(flags)
Definition: menu.h:6
static LPCSTR lpstr
Definition: font.c:51
#define MF_STRING
Definition: winuser.h:138

Definition at line 183 of file menu.c.

◆ IS_MAGIC_BITMAP

#define IS_MAGIC_BITMAP (   id)    ((id) && ((INT_PTR)(id) < 12) && ((INT_PTR)(id) >= -1))

Definition at line 63 of file menu.c.

◆ IS_STRING_ITEM

#define IS_STRING_ITEM (   flags)    (MF_STRING == MENU_ITEM_TYPE(flags))

Definition at line 64 of file menu.c.

◆ IS_SYSTEM_MENU

#define IS_SYSTEM_MENU (   MenuInfo)     (!!((MenuInfo)->fFlags & MNF_SYSMENU))

Definition at line 60 of file menu.c.

◆ ITEM_NEXT

#define ITEM_NEXT   1

Definition at line 93 of file menu.c.

◆ ITEM_PREV

#define ITEM_PREV   -1

Definition at line 92 of file menu.c.

◆ MAX_GOINTOSUBMENU

#define MAX_GOINTOSUBMENU   (0x10)

Definition at line 68 of file menu.c.

◆ MAX_MENU_ITEMS

#define MAX_MENU_ITEMS   (0x4000)

Definition at line 67 of file menu.c.

◆ MAXMENUDEPTH

#define MAXMENUDEPTH   30

Definition at line 43 of file menu.c.

◆ MENU_BAR_ITEMS_SPACE

#define MENU_BAR_ITEMS_SPACE   (12)

Definition at line 74 of file menu.c.

◆ MENU_COL_SPACE

#define MENU_COL_SPACE   4

Definition at line 71 of file menu.c.

◆ MENU_ITEM_HBMP_SPACE

#define MENU_ITEM_HBMP_SPACE   (5)

Definition at line 73 of file menu.c.

◆ MENU_TAB_SPACE

#define MENU_TAB_SPACE   (8)

Definition at line 76 of file menu.c.

◆ MENUITEMINFO_STATE_MASK

#define MENUITEMINFO_STATE_MASK   (STATE_MASK & ~(MF_BYPOSITION | MF_MOUSESELECT))

Definition at line 56 of file menu.c.

◆ MENUITEMINFO_TYPE_MASK

#define MENUITEMINFO_TYPE_MASK
Value:
MFT_RIGHTORDER | MFT_RIGHTJUSTIFY /* same as MF_HELP */ )
#define MFT_RIGHTORDER
Definition: winuser.h:756
#define MFT_SEPARATOR
Definition: winuser.h:755
#define MFT_OWNERDRAW
Definition: winuser.h:752
#define MFT_BITMAP
Definition: winuser.h:749
#define MFT_RIGHTJUSTIFY
Definition: winuser.h:754
#define MFT_STRING
Definition: winuser.h:757
#define MFT_MENUBREAK
Definition: winuser.h:751
#define MFT_RADIOCHECK
Definition: winuser.h:753
#define MFT_MENUBARBREAK
Definition: winuser.h:750

Definition at line 47 of file menu.c.

◆ MII_STATE_MASK

Definition at line 58 of file menu.c.

◆ MM_GETMENUHANDLE

#define MM_GETMENUHANDLE   (WM_USER + 1)

Definition at line 31 of file menu.c.

◆ MM_SETMENUHANDLE

#define MM_SETMENUHANDLE   (WM_USER + 0)

Definition at line 30 of file menu.c.

◆ MNS_STYLE_MASK

◆ SEPARATOR_HEIGHT

#define SEPARATOR_HEIGHT   (5)

Definition at line 75 of file menu.c.

◆ SHOW_DEBUGRECT

#define SHOW_DEBUGRECT   0

Definition at line 2846 of file menu.c.

◆ STATE_MASK

#define STATE_MASK   (~TYPE_MASK)

Definition at line 54 of file menu.c.

◆ TF_ENDMENU

#define TF_ENDMENU   0x10000

Definition at line 35 of file menu.c.

◆ TF_SKIPREMOVE

#define TF_SKIPREMOVE   0x40000

Definition at line 37 of file menu.c.

◆ TF_SUSPENDPOPUP

#define TF_SUSPENDPOPUP   0x20000

Definition at line 36 of file menu.c.

◆ TPM_BUTTONDOWN

#define TPM_BUTTONDOWN   0x40000000 /* menu was clicked before tracking */

Definition at line 89 of file menu.c.

◆ TPM_INTERNAL

#define TPM_INTERNAL   0xF0000000

Definition at line 88 of file menu.c.

◆ TPM_POPUPMENU

#define TPM_POPUPMENU   0x20000000 /* menu is a popup menu */

Definition at line 90 of file menu.c.

◆ TYPE_MASK

Definition at line 52 of file menu.c.

◆ UpdateMenuItemState

#define UpdateMenuItemState (   state,
  change 
)

Definition at line 95 of file menu.c.

◆ VALID_TPM_FLAGS

#define VALID_TPM_FLAGS
Value:
( \
TPM_LAYOUTRTL | TPM_NOANIMATION | TPM_VERNEGANIMATION | TPM_VERPOSANIMATION | \
TPM_HORNEGANIMATION | TPM_HORPOSANIMATION | TPM_RETURNCMD | \
)
#define TPM_CENTERALIGN
Definition: winuser.h:2395
#define TPM_RIGHTBUTTON
Definition: winuser.h:2399
#define TPM_BOTTOMALIGN
Definition: winuser.h:2404
#define TPM_RIGHTALIGN
Definition: winuser.h:2397
#define TPM_NONOTIFY
Definition: winuser.h:2405
#define TPM_VCENTERALIGN
Definition: winuser.h:2403
#define TPM_VERTICAL
Definition: winuser.h:2401
#define TPM_RETURNCMD
Definition: winuser.h:2406

Definition at line 6625 of file menu.c.

Function Documentation

◆ co_IntGetSubMenu()

PMENU FASTCALL co_IntGetSubMenu ( PMENU  pMenu,
int  nPos 
)

Definition at line 1348 of file menu.c.

1351{
1352 PITEM pItem;
1353 if (!(pItem = MENU_FindItem( &pMenu, (UINT*)&nPos, MF_BYPOSITION ))) return NULL;
1354 return pItem->spSubMenu;
1355}
#define NULL
Definition: types.h:112
unsigned int UINT
Definition: ndis.h:50
struct tagMENU * spSubMenu
Definition: ntuser.h:375
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
#define MF_BYPOSITION
Definition: winuser.h:203

Referenced by MENU_DoNextMenu(), and MENU_FindItemByKey().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserMenu  )

◆ get_win_sys_menu()

PMENU get_win_sys_menu ( HWND  hwnd)

Definition at line 258 of file menu.c.

259{
260 PMENU ret = 0;
262 if (win)
263 {
264 ret = UserGetMenuObject(win->SystemMenu);
265 }
266 return ret;
267}
return ret
Definition: mutex.c:146
static real win[4][36]
Definition: ntuser.h:694
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:4
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:100
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by MENU_DoNextMenu(), MENU_PtMenu(), MENU_TrackKbdMenuBar(), and MENU_TrackMouseMenuBar().

◆ IntCheckMenuItem()

DWORD FASTCALL IntCheckMenuItem ( PMENU  MenuObject,
UINT  uIDCheckItem,
UINT  uCheck 
)

Definition at line 1259 of file menu.c.

1260{
1261 PITEM MenuItem;
1262 DWORD res;
1263
1264 if (!(MenuItem = MENU_FindItem( &MenuObject, &uIDCheckItem, uCheck ))) return -1;
1265
1266 res = (DWORD)(MenuItem->fState & MF_CHECKED);
1267
1268 MenuItem->fState ^= (res ^ uCheck) & MF_CHECKED;
1269
1270 return res;
1271}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define DWORD
Definition: nt_native.h:44
UINT fState
Definition: ntuser.h:373
#define MF_CHECKED
Definition: winuser.h:132

Referenced by NtUserCheckMenuItem().

◆ 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 FALSE
Definition: types.h:117
struct tagMENU MENU
@ TYPE_MENU
Definition: ntuser.h:42
#define NO_SELECTED_ITEM
Definition: ntuser.h:413
struct tagMENU * PMENU
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
ULONG fFlags
Definition: ntuser.h:418
ULONG cyMenu
Definition: ntuser.h:423
struct _WND * spwndNotify
Definition: ntuser.h:425
INT iItem
Definition: ntuser.h:419
UINT cItems
Definition: ntuser.h:421
DWORD dwContextHelpId
Definition: ntuser.h:428
BOOL TimeToHide
Definition: ntuser.h:438
DWORD_PTR dwMenuData
Definition: ntuser.h:430
HWND hWnd
Definition: ntuser.h:437
ULONG cxMenu
Definition: ntuser.h:422
ULONG cyMax
Definition: ntuser.h:429
INT iTop
Definition: ntuser.h:432
INT iMaxTop
Definition: ntuser.h:433
HBRUSH hbrBack
Definition: ntuser.h:431
ULONG cxTextAlign
Definition: ntuser.h:424
PITEM rgItems
Definition: ntuser.h:426
BOOL FASTCALL IntCloneMenuItems(PMENU Destination, PMENU Source)
Definition: menu.c:771
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568

Referenced by MENU_GetSystemMenu().

◆ IntCloneMenuItems()

BOOL FASTCALL IntCloneMenuItems ( PMENU  Destination,
PMENU  Source 
)

Definition at line 771 of file menu.c.

772{
773 PITEM MenuItem, NewMenuItem = NULL;
774 UINT i;
775
776 if(!Source->cItems)
777 return FALSE;
778
779 NewMenuItem = DesktopHeapAlloc(Destination->head.rpdesk, Source->cItems * sizeof(ITEM));
780 if(!NewMenuItem) return FALSE;
781
782 RtlZeroMemory(NewMenuItem, Source->cItems * sizeof(ITEM));
783
784 Destination->rgItems = NewMenuItem;
785
786 MenuItem = Source->rgItems;
787 for (i = 0; i < Source->cItems; i++, MenuItem++, NewMenuItem++)
788 {
789 NewMenuItem->fType = MenuItem->fType;
790 NewMenuItem->fState = MenuItem->fState;
791 NewMenuItem->wID = MenuItem->wID;
792 NewMenuItem->spSubMenu = MenuItem->spSubMenu;
793 NewMenuItem->hbmpChecked = MenuItem->hbmpChecked;
794 NewMenuItem->hbmpUnchecked = MenuItem->hbmpUnchecked;
795 NewMenuItem->dwItemData = MenuItem->dwItemData;
796 if (MenuItem->lpstr.Length)
797 {
798 NewMenuItem->lpstr.Length = 0;
799 NewMenuItem->lpstr.MaximumLength = MenuItem->lpstr.MaximumLength;
800 NewMenuItem->lpstr.Buffer = DesktopHeapAlloc(Destination->head.rpdesk, MenuItem->lpstr.MaximumLength);
801 if (!NewMenuItem->lpstr.Buffer)
802 {
803 DesktopHeapFree(Destination->head.rpdesk, NewMenuItem);
804 break;
805 }
806 RtlCopyUnicodeString(&NewMenuItem->lpstr, &MenuItem->lpstr);
807 NewMenuItem->lpstr.Buffer[MenuItem->lpstr.Length / sizeof(WCHAR)] = 0;
808 NewMenuItem->Xlpstr = NewMenuItem->lpstr.Buffer;
809 }
810 else
811 {
812 NewMenuItem->lpstr.Buffer = MenuItem->lpstr.Buffer;
813 NewMenuItem->Xlpstr = NewMenuItem->lpstr.Buffer;
814 }
815 NewMenuItem->hbmp = MenuItem->hbmp;
816 Destination->cItems = i + 1;
817 }
818 return TRUE;
819}
#define TRUE
Definition: types.h:120
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
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3043
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
Definition: fontsub.cpp:36
USHORT MaximumLength
Definition: env_spec_w32.h:370
HBITMAP hbmp
Definition: ntuser.h:388
HANDLE hbmpChecked
Definition: ntuser.h:376
DWORD_PTR dwItemData
Definition: ntuser.h:380
UINT wID
Definition: ntuser.h:374
UNICODE_STRING lpstr
Definition: ntuser.h:392
UINT fType
Definition: ntuser.h:372
USHORT * Xlpstr
Definition: ntuser.h:378
HANDLE hbmpUnchecked
Definition: ntuser.h:377
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IntCloneMenu().

◆ IntCreateMenu()

PMENU FASTCALL IntCreateMenu ( _Out_ PHANDLE  Handle,
_In_ BOOL  IsMenuBar,
_In_ PDESKTOP  Desktop,
_In_ PPROCESSINFO  ppi 
)

Definition at line 729 of file menu.c.

734{
735 PMENU Menu;
736
738 Desktop,
739 ppi->ptiList,
740 Handle,
741 TYPE_MENU,
742 sizeof(MENU));
743 if(!Menu)
744 {
745 *Handle = 0;
746 return NULL;
747 }
748
749 Menu->cyMax = 0; /* Default */
750 Menu->hbrBack = NULL; /* No brush */
751 Menu->dwContextHelpId = 0; /* Default */
752 Menu->dwMenuData = 0; /* Default */
753 Menu->iItem = NO_SELECTED_ITEM; // Focused item
754 Menu->fFlags = (IsMenuBar ? 0 : MNF_POPUP);
755 Menu->spwndNotify = NULL;
756 Menu->cyMenu = 0; // Height
757 Menu->cxMenu = 0; // Width
758 Menu->cItems = 0; // Item count
759 Menu->iTop = 0;
760 Menu->iMaxTop = 0;
761 Menu->cxTextAlign = 0;
762 Menu->rgItems = NULL;
763
764 Menu->hWnd = NULL;
765 Menu->TimeToHide = FALSE;
766
767 return Menu;
768}
ULONG Handle
Definition: gdb_input.c:15
#define MNF_POPUP
Definition: ntuser.h:402

Referenced by IntSetMenuItemInfo(), and UserCreateMenu().

◆ IntDestroyMenu()

BOOL IntDestroyMenu ( PMENU  pMenu,
BOOL  bRecurse 
)

Definition at line 269 of file menu.c.

270{
271 PMENU SubMenu;
272
274 if (pMenu->rgItems) /* recursively destroy submenus */
275 {
276 int i;
277 ITEM *item = pMenu->rgItems;
278 for (i = pMenu->cItems; i > 0; i--, item++)
279 {
280 SubMenu = item->spSubMenu;
281 item->spSubMenu = NULL;
282
283 /* Remove Item Text */
284 FreeMenuText(pMenu,item);
285
286 /* Remove Item Bitmap and set it for this process */
287 if (item->hbmp && !(item->fState & MFS_HBMMENUBMP))
288 {
290 item->hbmp = NULL;
291 }
292
293 /* Remove Item submenu */
294 if (bRecurse && SubMenu)//VerifyMenu(SubMenu))
295 {
296 /* Release submenu since it was referenced when inserted */
297 IntReleaseMenuObject(SubMenu);
298 IntDestroyMenuObject(SubMenu, bRecurse);
299 }
300 }
301 /* Free the Item */
302 DesktopHeapFree(pMenu->head.rpdesk, pMenu->rgItems );
303 pMenu->rgItems = NULL;
304 pMenu->cItems = 0;
305 }
306 return TRUE;
307}
#define MFS_HBMMENUBMP
Definition: ntuser.h:368
#define IntReleaseMenuObject(MenuObj)
Definition: menu.h:130
#define ASSERT(a)
Definition: mode.c:44
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231
struct _DESKTOP * rpdesk
Definition: ntuser.h:219
PROCDESKHEAD head
Definition: ntuser.h:417
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1261
BOOL FASTCALL IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
Definition: menu.c:317
#define FreeMenuText(Menu, MenuItem)
Definition: menu.c:183

Referenced by IntDestroyMenuObject().

◆ IntDestroyMenuObject()

BOOL FASTCALL IntDestroyMenuObject ( PMENU  Menu,
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 {
330 if (Window)
331 {
332 //Window->IDMenu = 0; Only in Win9x!! wine win test_SetMenu test...
333
334 /* DestroyMenu should not destroy system menu popup owner */
335 if ((Menu->fFlags & (MNF_POPUP | MNF_SYSSUBMENU)) == MNF_POPUP)
336 {
337 // Should we check it to see if it has Class?
338 ERR("FIXME Pop up menu window thing'ie\n");
339 //co_UserDestroyWindow( Window );
340 //Menu->hWnd = 0;
341 }
342 }
343 }
344
345 if (!UserMarkObjectDestroy(Menu)) return TRUE;
346
347 /* Remove all menu items */
348 IntDestroyMenu( Menu, bRecurse);
349
351 TRACE("IntDestroyMenuObject %d\n",ret);
352 return ret;
353 }
354 }
355 return FALSE;
356}
#define ERR(fmt,...)
Definition: precomp.h:57
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MNF_SYSSUBMENU
Definition: ntuser.h:408
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
#define TRACE(s)
Definition: solgame.cpp:4
Definition: window.c:28
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().

◆ IntDrawMenuBarTemp()

DWORD WINAPI IntDrawMenuBarTemp ( PWND  pWnd,
HDC  hDC,
LPRECT  Rect,
PMENU  pMenu,
HFONT  Font 
)

Definition at line 2685 of file menu.c.

2686{
2687 UINT i;
2688 HFONT FontOld = NULL;
2689 BOOL flat_menu = FALSE;
2690
2691 UserSystemParametersInfo(SPI_GETFLATMENU, 0, &flat_menu, 0);
2692
2693 if (!pMenu)
2694 {
2695 pMenu = UserGetMenuObject(UlongToHandle(pWnd->IDMenu));
2696 }
2697
2698 if (!Font)
2699 {
2700 Font = ghMenuFont;
2701 }
2702
2703 if (Rect == NULL || !pMenu)
2704 {
2706 }
2707
2708 TRACE("(%x, %x, %p, %x, %x)\n", pWnd, hDC, Rect, pMenu, Font);
2709
2710 FontOld = NtGdiSelectFont(hDC, Font);
2711
2712 if (pMenu->cyMenu == 0)
2713 {
2714 MENU_MenuBarCalcSize(hDC, Rect, pMenu, pWnd);
2715 }
2716
2717 Rect->bottom = Rect->top + pMenu->cyMenu;
2718
2719 FillRect(hDC, Rect, IntGetSysColorBrush(flat_menu ? COLOR_MENUBAR : COLOR_MENU));
2720
2723 GreMoveTo(hDC, Rect->left, Rect->bottom - 1, NULL);
2724 NtGdiLineTo(hDC, Rect->right, Rect->bottom - 1);
2725
2726 if (pMenu->cItems == 0)
2727 {
2728 NtGdiSelectFont(hDC, FontOld);
2730 }
2731
2732 for (i = 0; i < pMenu->cItems; i++)
2733 {
2734 MENU_DrawMenuItem(pWnd, pMenu, pWnd, hDC, &pMenu->rgItems[i], pMenu->cyMenu, TRUE, ODA_DRAWENTIRE);
2735 }
2736
2737 NtGdiSelectFont(hDC, FontOld);
2738
2739 return pMenu->cyMenu;
2740}
static HDC hDC
Definition: 3dtext.c:33
#define UlongToHandle(ul)
Definition: basetsd.h:97
COLORREF FASTCALL IntSetDCPenColor(HDC, COLORREF)
Definition: dcutil.c:259
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
BOOL FASTCALL GreMoveTo(HDC hdc, INT x, INT y, LPPOINT pptOut)
Definition: line.c:110
DWORD FASTCALL IntGetSysColor(INT nIndex)
Definition: stockobj.c:323
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetStockObject(_In_ INT iObject)
__kernel_entry W32KAPI HPEN APIENTRY NtGdiSelectPen(_In_ HDC hdc, _In_ HPEN hpen)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiLineTo(_In_ HDC hdc, _In_ INT x, _In_ INT y)
__kernel_entry W32KAPI HFONT APIENTRY NtGdiSelectFont(_In_ HDC hdc, _In_ HFONT hf)
Definition: dcobjs.c:597
UINT_PTR IDMenu
Definition: ntuser.h:731
static void FASTCALL MENU_DrawMenuItem(PWND Wnd, PMENU Menu, PWND WndOwner, HDC hdc, PITEM lpitem, UINT Height, BOOL menuBar, UINT odaction)
Definition: menu.c:2204
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:210
BOOL FASTCALL UserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2116
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define COLOR_MENU
Definition: winuser.h:928
#define ODA_DRAWENTIRE
Definition: winuser.h:2561
#define SM_CYMENU
Definition: winuser.h:987
#define COLOR_3DFACE
Definition: winuser.h:940

Referenced by MENU_DrawMenuBar(), and NtUserDrawMenuBarTemp().

◆ IntEnableMenuItem()

UINT FASTCALL IntEnableMenuItem ( PMENU  MenuObject,
UINT  uIDEnableItem,
UINT  uEnable 
)

Definition at line 1217 of file menu.c.

1218{
1219 PITEM MenuItem;
1220 UINT res;
1221
1222 if (!(MenuItem = MENU_FindItem( &MenuObject, &uIDEnableItem, uEnable ))) return (UINT)-1;
1223
1224 res = MenuItem->fState & (MF_GRAYED | MF_DISABLED);
1225
1226 MenuItem->fState ^= (res ^ uEnable) & (MF_GRAYED | MF_DISABLED);
1227
1228 /* If the close item in the system menu change update the close button */
1229 if (res != uEnable)
1230 {
1231 switch (MenuItem->wID) // More than just close.
1232 {
1233 case SC_CLOSE:
1234 case SC_MAXIMIZE:
1235 case SC_MINIMIZE:
1236 case SC_MOVE:
1237 case SC_RESTORE:
1238 case SC_SIZE:
1239 if (MenuObject->fFlags & MNF_SYSSUBMENU && MenuObject->spwndNotify != 0)
1240 {
1241 //RECTL rc = MenuObject->spwndNotify->rcWindow;
1242
1243 /* Refresh the frame to reflect the change */
1244 //IntMapWindowPoints(0, MenuObject->spwndNotify, (POINT *)&rc, 2);
1245 //rc.bottom = 0;
1246 //co_UserRedrawWindow(MenuObject->spwndNotify, &rc, 0, RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN);
1247
1248 // Allow UxTheme!
1249 UserPaintCaption(MenuObject->spwndNotify, DC_BUTTONS);
1250 }
1251 default:
1252 break;
1253 }
1254 }
1255 return res;
1256}
BOOL UserPaintCaption(PWND pWnd, INT Flags)
Definition: defwnd.c:398
#define SC_SIZE
Definition: winuser.h:2603
#define SC_MINIMIZE
Definition: winuser.h:2605
#define SC_CLOSE
Definition: winuser.h:2611
#define SC_MOVE
Definition: winuser.h:2604
#define SC_RESTORE
Definition: winuser.h:2617
#define SC_MAXIMIZE
Definition: winuser.h:2607
#define MF_GRAYED
Definition: winuser.h:129
#define MF_DISABLED
Definition: winuser.h:130

Referenced by MENU_InitSysMenuPopup(), and NtUserEnableMenuItem().

◆ IntFindSubMenu()

UINT FASTCALL IntFindSubMenu ( HMENU hMenu,
HMENU  hSubTarget 
)

Definition at line 5041 of file menu.c.

5042{
5043 PMENU menu, pSubTarget;
5044 UINT Pos;
5045 if (((*hMenu)==(HMENU)0xffff) ||(!(menu = UserGetMenuObject(*hMenu))))
5046 return NO_SELECTED_ITEM;
5047
5048 pSubTarget = UserGetMenuObject(hSubTarget);
5049
5050 Pos = MENU_FindSubMenu(&menu, pSubTarget );
5051
5052 *hMenu = (menu ? UserHMGetHandle(menu) : NULL);
5053
5054 return Pos;
5055}
ush Pos
Definition: deflate.h:92
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
static UINT FASTCALL MENU_FindSubMenu(PMENU *menu, PMENU SubTarget)
Definition: menu.c:564

Referenced by co_IntTranslateAccelerator().

◆ IntGetDialogBaseUnits()

LONG IntGetDialogBaseUnits ( VOID  )

Definition at line 1800 of file menu.c.

1801{
1802 static DWORD units;
1803
1804 if (!units)
1805 {
1806 HDC hdc;
1807 SIZE size;
1808
1809 if ((hdc = UserGetDCEx(NULL, NULL, DCX_CACHE)))
1810 {
1812 if (size.cx) units = MAKELONG( size.cx, size.cy );
1813 UserReleaseDC( 0, hdc, FALSE);
1814 }
1815 }
1816 return units;
1817}
GLsizeiptr size
Definition: glext.h:5919
GLfloat units
Definition: glext.h:11727
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
DWORD * PDWORD
Definition: pedump.c:68
#define MAKELONG(a, b)
Definition: typedefs.h:249
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:918
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
DWORD FASTCALL IntGetCharDimensions(_In_ HDC hdc, _Out_opt_ PTEXTMETRICW ptm, _Out_opt_ PDWORD height)
Definition: font.c:335
#define DCX_CACHE
Definition: winuser.h:2133

Referenced by MENU_CalcItemSize().

◆ IntGetMenu()

PMENU WINAPI IntGetMenu ( HWND  hWnd)

Definition at line 248 of file menu.c.

249{
251
252 if (!Wnd)
253 return NULL;
254
256}
HWND hWnd
Definition: settings.c:17

Referenced by MENU_ButtonUp(), MENU_DoNextMenu(), MENU_PtMenu(), MENU_TrackKbdMenuBar(), and MENU_TrackMouseMenuBar().

◆ IntGetMenuDefaultItem()

UINT FASTCALL IntGetMenuDefaultItem ( PMENU  MenuObject,
UINT  fByPos,
UINT  gmdiFlags,
DWORD gismc 
)

Definition at line 1315 of file menu.c.

1316{
1317 UINT i = 0;
1318 PITEM MenuItem = MenuObject->rgItems;
1319
1320 /* empty menu */
1321 if (!MenuItem) return -1;
1322
1323 while ( !( MenuItem->fState & MFS_DEFAULT ) )
1324 {
1325 i++; MenuItem++;
1326 if (i >= MenuObject->cItems ) return -1;
1327 }
1328
1329 /* default: don't return disabled items */
1330 if ( (!(GMDI_USEDISABLED & gmdiFlags)) && (MenuItem->fState & MFS_DISABLED )) return -1;
1331
1332 /* search rekursiv when needed */
1333 if ( (gmdiFlags & GMDI_GOINTOPOPUPS) && MenuItem->spSubMenu )
1334 {
1335 UINT ret;
1336 (*gismc)++;
1337 ret = IntGetMenuDefaultItem( MenuItem->spSubMenu, fByPos, gmdiFlags, gismc );
1338 (*gismc)--;
1339 if ( -1 != ret ) return ret;
1340
1341 /* when item not found in submenu, return the popup item */
1342 }
1343 return ( fByPos ) ? i : MenuItem->wID;
1344}
UINT FASTCALL IntGetMenuDefaultItem(PMENU MenuObject, UINT fByPos, UINT gmdiFlags, DWORD *gismc)
Definition: menu.c:1315
#define GMDI_USEDISABLED
Definition: winuser.h:2145
#define MFS_DISABLED
Definition: winuser.h:760
#define MFS_DEFAULT
Definition: winuser.h:759
#define GMDI_GOINTOPOPUPS
Definition: winuser.h:2144

Referenced by GetMenuDefaultItem(), and IntGetMenuDefaultItem().

◆ IntGetMenuInfo()

BOOL FASTCALL IntGetMenuInfo ( PMENU  Menu,
PROSMENUINFO  lpmi 
)

Definition at line 879 of file menu.c.

880{
881 if(lpmi->fMask & MIM_BACKGROUND)
882 lpmi->hbrBack = Menu->hbrBack;
883 if(lpmi->fMask & MIM_HELPID)
884 lpmi->dwContextHelpID = Menu->dwContextHelpId;
885 if(lpmi->fMask & MIM_MAXHEIGHT)
886 lpmi->cyMax = Menu->cyMax;
887 if(lpmi->fMask & MIM_MENUDATA)
888 lpmi->dwMenuData = Menu->dwMenuData;
889 if(lpmi->fMask & MIM_STYLE)
890 lpmi->dwStyle = Menu->fFlags & MNS_STYLE_MASK;
891
892 if (sizeof(MENUINFO) < lpmi->cbSize)
893 {
894 lpmi->cItems = Menu->cItems;
895
896 lpmi->iItem = Menu->iItem;
897 lpmi->cxMenu = Menu->cxMenu;
898 lpmi->cyMenu = Menu->cyMenu;
899 lpmi->spwndNotify = Menu->spwndNotify;
900 lpmi->cxTextAlign = Menu->cxTextAlign;
901 lpmi->iTop = Menu->iTop;
902 lpmi->iMaxTop = Menu->iMaxTop;
903 lpmi->dwArrowsOn = Menu->dwArrowsOn;
904
905 lpmi->fFlags = Menu->fFlags;
906 lpmi->Self = UserHMGetHandle(Menu);
907 lpmi->TimeToHide = Menu->TimeToHide;
908 lpmi->Wnd = Menu->hWnd;
909 }
910 return TRUE;
911}
DWORD dwArrowsOn
Definition: ntuser.h:434
INT iTop
Definition: menu.h:91
INT iMaxTop
Definition: menu.h:92
HMENU Self
Definition: menu.h:95
DWORD dwContextHelpID
Definition: menu.h:81
HBRUSH hbrBack
Definition: menu.h:80
UINT cItems
Definition: menu.h:86
UINT iItem
Definition: menu.h:85
DWORD dwStyle
Definition: menu.h:78
UINT cyMax
Definition: menu.h:79
HWND Wnd
Definition: menu.h:96
ULONG_PTR dwMenuData
Definition: menu.h:82
ULONG cxTextAlign
Definition: menu.h:89
ULONG fFlags
Definition: menu.h:84
BOOL TimeToHide
Definition: menu.h:97
PWND spwndNotify
Definition: menu.h:90
DWORD cbSize
Definition: menu.h:76
WORD cyMenu
Definition: menu.h:88
WORD cxMenu
Definition: menu.h:87
DWORD dwArrowsOn
Definition: menu.h:93
DWORD fMask
Definition: menu.h:77
#define MNS_STYLE_MASK
Definition: menu.c:45

Referenced by UserMenuInfo().

◆ IntGetMenuItemInfo()

BOOL FASTCALL IntGetMenuItemInfo ( PMENU  Menu,
PITEM  MenuItem,
PROSMENUITEMINFO  lpmii 
)

Definition at line 962 of file menu.c.

964{
966
967 if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
968 {
969 lpmii->fType = MenuItem->fType;
970 }
971 if(lpmii->fMask & MIIM_BITMAP)
972 {
973 lpmii->hbmpItem = MenuItem->hbmp;
974 }
975 if(lpmii->fMask & MIIM_CHECKMARKS)
976 {
977 lpmii->hbmpChecked = MenuItem->hbmpChecked;
978 lpmii->hbmpUnchecked = MenuItem->hbmpUnchecked;
979 }
980 if(lpmii->fMask & MIIM_DATA)
981 {
982 lpmii->dwItemData = MenuItem->dwItemData;
983 }
984 if(lpmii->fMask & MIIM_ID)
985 {
986 lpmii->wID = MenuItem->wID;
987 }
988 if(lpmii->fMask & MIIM_STATE)
989 {
990 lpmii->fState = MenuItem->fState;
991 }
992 if(lpmii->fMask & MIIM_SUBMENU)
993 {
994 lpmii->hSubMenu = (MenuItem->spSubMenu ? UserHMGetHandle(MenuItem->spSubMenu) : NULL);
995 }
996
997 if ((lpmii->fMask & MIIM_STRING) ||
998 ((lpmii->fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(lpmii->fType) == MF_STRING)))
999 {
1000 if (lpmii->dwTypeData == NULL)
1001 {
1002 lpmii->cch = MenuItem->lpstr.Length / sizeof(WCHAR);
1003 }
1004 else
1005 {
1006 Status = MmCopyToCaller(lpmii->dwTypeData, MenuItem->lpstr.Buffer,
1007 min(lpmii->cch * sizeof(WCHAR),
1008 MenuItem->lpstr.MaximumLength));
1009 if (! NT_SUCCESS(Status))
1010 {
1012 return FALSE;
1013 }
1014 }
1015 }
1016
1017 if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
1018 {
1019 lpmii->Rect.left = MenuItem->xItem;
1020 lpmii->Rect.top = MenuItem->yItem;
1021 lpmii->Rect.right = MenuItem->cxItem; // Do this for now......
1022 lpmii->Rect.bottom = MenuItem->cyItem;
1023 lpmii->dxTab = MenuItem->dxTab;
1024 lpmii->lpstr = MenuItem->lpstr.Buffer;
1025 lpmii->maxBmpSize.cx = MenuItem->cxBmp;
1026 lpmii->maxBmpSize.cy = MenuItem->cyBmp;
1027 }
1028
1029 return TRUE;
1030}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define min(a, b)
Definition: monoChain.cc:55
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
INT cyBmp
Definition: ntuser.h:390
ULONG yItem
Definition: ntuser.h:382
ULONG dxTab
Definition: ntuser.h:385
ULONG xItem
Definition: ntuser.h:381
INT cxBmp
Definition: ntuser.h:389
ULONG cxItem
Definition: ntuser.h:383
ULONG cyItem
Definition: ntuser.h:384
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
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
#define MIIM_STRING
Definition: winuser.h:738
#define MIIM_ID
Definition: winuser.h:733
#define MIIM_CHECKMARKS
Definition: winuser.h:735
#define MIIM_FTYPE
Definition: winuser.h:740
#define MIIM_STATE
Definition: winuser.h:732
#define MIIM_SUBMENU
Definition: winuser.h:734
#define MIIM_BITMAP
Definition: winuser.h:739
#define MIIM_DATA
Definition: winuser.h:737
#define MIIM_TYPE
Definition: winuser.h:736

Referenced by IntMenuItemInfo(), and UserMenuItemInfo().

◆ IntGetMenuItemRect()

BOOL FASTCALL IntGetMenuItemRect ( PWND  pWnd,
PMENU  Menu,
UINT  uItem,
PRECTL  Rect 
)

Definition at line 5256 of file menu.c.

5261{
5262 LONG XMove, YMove;
5263 PITEM MenuItem;
5264 UINT I = uItem;
5265
5266 if ((MenuItem = MENU_FindItem (&Menu, &I, MF_BYPOSITION)))
5267 {
5268 Rect->left = MenuItem->xItem;
5269 Rect->top = MenuItem->yItem;
5270 Rect->right = MenuItem->cxItem; // Do this for now......
5271 Rect->bottom = MenuItem->cyItem;
5272 }
5273 else
5274 {
5275 ERR("Failed Item Lookup! %u\n", uItem);
5276 return FALSE;
5277 }
5278
5279 if (!pWnd)
5280 {
5281 HWND hWnd = Menu->hWnd;
5282 if (!(pWnd = UserGetWindowObject(hWnd))) return FALSE;
5283 }
5284
5285 if (Menu->fFlags & MNF_POPUP)
5286 {
5287 XMove = pWnd->rcClient.left;
5288 YMove = pWnd->rcClient.top;
5289 }
5290 else
5291 {
5292 XMove = pWnd->rcWindow.left;
5293 YMove = pWnd->rcWindow.top;
5294 }
5295
5296 Rect->left += XMove;
5297 Rect->top += YMove;
5298 Rect->right += XMove;
5299 Rect->bottom += YMove;
5300
5301 return TRUE;
5302}
#define I(s)
long LONG
Definition: pedump.c:60
RECT rcClient
Definition: ntuser.h:717
RECT rcWindow
Definition: ntuser.h:716
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:124

Referenced by NtUserGetMenuBarInfo().

◆ 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}

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

◆ IntGetMenuState()

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

Definition at line 5001 of file menu.c.

5002{
5003 PMENU MenuObject;
5004 PITEM pItem;
5005
5006 if (!(MenuObject = UserGetMenuObject(hMenu)))
5007 {
5008 return (UINT)-1;
5009 }
5010
5011 if (!(pItem = MENU_FindItem( &MenuObject, &uId, uFlags ))) return -1;
5012
5013 if (pItem->spSubMenu)
5014 {
5015 return (pItem->spSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|MF_POPUP) & 0xff);
5016 }
5017 else
5018 return (pItem->fType | pItem->fState);
5019}
UINT uFlags
Definition: api.c:59
#define MF_POPUP
Definition: winuser.h:136

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

◆ IntGetSubMenu()

HMENU FASTCALL IntGetSubMenu ( HMENU  hMenu,
int  nPos 
)

Definition at line 5021 of file menu.c.

5022{
5023 PMENU MenuObject;
5024 PITEM pItem;
5025
5026 if (!(MenuObject = UserGetMenuObject(hMenu)))
5027 {
5028 return NULL;
5029 }
5030
5031 if (!(pItem = MENU_FindItem( &MenuObject, (UINT*)&nPos, MF_BYPOSITION ))) return NULL;
5032
5033 if (pItem->spSubMenu)
5034 {
5035 HMENU hsubmenu = UserHMGetHandle(pItem->spSubMenu);
5036 return hsubmenu;
5037 }
5038 return NULL;
5039}

Referenced by IntGetSystemMenu().

◆ IntGetSystemMenu()

PMENU FASTCALL IntGetSystemMenu ( PWND  Window,
BOOL  bRevert 
)

Definition at line 5409 of file menu.c.

5410{
5411 PMENU Menu;
5412
5413 if (bRevert)
5414 {
5415 if (Window->SystemMenu)
5416 {
5417 Menu = UserGetMenuObject(Window->SystemMenu);
5418 if (Menu && !(Menu->fFlags & MNF_SYSDESKMN))
5419 {
5421 Window->SystemMenu = NULL;
5422 }
5423 }
5424 }
5425 else
5426 {
5427 Menu = Window->SystemMenu ? UserGetMenuObject(Window->SystemMenu) : NULL;
5428 if ((!Menu || Menu->fFlags & MNF_SYSDESKMN) && Window->style & WS_SYSMENU)
5429 {
5431 Window->SystemMenu = Menu ? UserHMGetHandle(Menu) : NULL;
5432 }
5433 }
5434
5435 if (Window->SystemMenu)
5436 {
5437 HMENU hMenu = IntGetSubMenu( Window->SystemMenu, 0);
5438 /* Store the dummy sysmenu handle to facilitate the refresh */
5439 /* of the close button if the SC_CLOSE item change */
5440 Menu = UserGetMenuObject(hMenu);
5441 if (Menu)
5442 {
5443 Menu->spwndNotify = Window;
5444 Menu->fFlags |= MNF_SYSSUBMENU;
5445 }
5446 return Menu;
5447 }
5448 return NULL;
5449}
#define MNF_SYSDESKMN
Definition: ntuser.h:407
#define WS_SYSMENU
Definition: pedump.c:629
PMENU FASTCALL MENU_GetSystemMenu(PWND Window, PMENU Popup)
Definition: menu.c:5304
HMENU FASTCALL IntGetSubMenu(HMENU hMenu, int nPos)
Definition: menu.c:5021

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

◆ intGetTitleBarInfo()

BOOLEAN APIENTRY intGetTitleBarInfo ( PWND  pWindowObject,
PTITLEBARINFO  bti 
)

Definition at line 4830 of file menu.c.

4831{
4832
4833 DWORD dwStyle = 0;
4834 DWORD dwExStyle = 0;
4835 BOOLEAN retValue = TRUE;
4836
4837 if (bti->cbSize == sizeof(TITLEBARINFO))
4838 {
4839 RtlZeroMemory(&bti->rgstate[0],sizeof(DWORD)*(CCHILDREN_TITLEBAR+1));
4840
4842
4843 dwStyle = pWindowObject->style;
4844 dwExStyle = pWindowObject->ExStyle;
4845
4846 bti->rcTitleBar.top = 0;
4847 bti->rcTitleBar.left = 0;
4848 bti->rcTitleBar.right = pWindowObject->rcWindow.right - pWindowObject->rcWindow.left;
4849 bti->rcTitleBar.bottom = pWindowObject->rcWindow.bottom - pWindowObject->rcWindow.top;
4850
4851 /* Is it iconiced ? */
4852 if ((dwStyle & WS_ICONIC)!=WS_ICONIC)
4853 {
4854 /* Remove frame from rectangle */
4855 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
4856 {
4857 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXFRAME) and UserGetSystemMetrics(SM_CYFRAME) */
4859 }
4860 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
4861 {
4862 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXDLGFRAME) and UserGetSystemMetrics(SM_CYDLGFRAME) */
4864 }
4865 else if (HAS_THINFRAME( dwStyle, dwExStyle))
4866 {
4867 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
4869 }
4870
4871 /* We have additional border information if the window
4872 * is a child (but not an MDI child) */
4873 if ( (dwStyle & WS_CHILD) &&
4874 ((dwExStyle & WS_EX_MDICHILD) == 0 ) )
4875 {
4876 if (dwExStyle & WS_EX_CLIENTEDGE)
4877 {
4878 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXEDGE) and UserGetSystemMetrics(SM_CYEDGE) */
4880 }
4881
4882 if (dwExStyle & WS_EX_STATICEDGE)
4883 {
4884 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
4886 }
4887 }
4888 }
4889
4890 bti->rcTitleBar.top += pWindowObject->rcWindow.top;
4891 bti->rcTitleBar.left += pWindowObject->rcWindow.left;
4892 bti->rcTitleBar.right += pWindowObject->rcWindow.left;
4893
4894 bti->rcTitleBar.bottom = bti->rcTitleBar.top;
4895 if (dwExStyle & WS_EX_TOOLWINDOW)
4896 {
4897 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CYSMCAPTION) */
4899 }
4900 else
4901 {
4902 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CYCAPTION) and UserGetSystemMetrics(SM_CXSIZE) */
4905 }
4906
4907 if (dwStyle & WS_CAPTION)
4908 {
4910 if (dwStyle & WS_SYSMENU)
4911 {
4912 if (!(dwStyle & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX)))
4913 {
4916 }
4917 else
4918 {
4919 if (!(dwStyle & WS_MINIMIZEBOX))
4920 {
4922 }
4923 if (!(dwStyle & WS_MAXIMIZEBOX))
4924 {
4926 }
4927 }
4928
4929 if (!(dwExStyle & WS_EX_CONTEXTHELP))
4930 {
4932 }
4933 if (pWindowObject->pcls->style & CS_NOCLOSE)
4934 {
4936 }
4937 }
4938 else
4939 {
4944 }
4945 }
4946 else
4947 {
4949 }
4950 }
4951 else
4952 {
4954 retValue = FALSE;
4955 }
4956
4957 return retValue;
4958}
unsigned char BOOLEAN
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_ICONIC
Definition: pedump.c:641
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_MINIMIZEBOX
Definition: pedump.c:631
UINT style
Definition: ntuser.h:580
DWORD ExStyle
Definition: ntuser.h:704
PCLS pcls
Definition: ntuser.h:720
DWORD style
Definition: ntuser.h:706
DWORD rgstate[CCHILDREN_TITLEBAR+1]
Definition: winuser.h:3838
VOID FASTCALL RECTL_vInflateRect(_Inout_ RECTL *rect, _In_ INT dx, _In_ INT dy)
Definition: rect.c:101
#define HAS_DLGFRAME(Style, ExStyle)
Definition: window.h:9
#define HAS_THINFRAME(Style, ExStyle)
Definition: window.h:17
#define HAS_THICKFRAME(Style, ExStyle)
Definition: window.h:13
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define WS_EX_STATICEDGE
Definition: winuser.h:403
#define SM_CYEDGE
Definition: winuser.h:1020
#define SM_CXEDGE
Definition: winuser.h:1019
#define SM_CXFRAME
Definition: winuser.h:1005
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define CCHILDREN_TITLEBAR
Definition: winuser.h:3833
#define SM_CXSIZE
Definition: winuser.h:1002
#define SM_CYFRAME
Definition: winuser.h:1007
#define SM_CYBORDER
Definition: winuser.h:976
#define STATE_SYSTEM_FOCUSABLE
Definition: winuser.h:2958
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define SM_CXBORDER
Definition: winuser.h:975
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2953
#define SM_CXDLGFRAME
Definition: winuser.h:977
#define STATE_SYSTEM_UNAVAILABLE
Definition: winuser.h:2938
#define SM_CYSMCAPTION
Definition: winuser.h:1025
#define SM_CYDLGFRAME
Definition: winuser.h:979
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WS_EX_CONTEXTHELP
Definition: winuser.h:386
#define SM_CYCAPTION
Definition: winuser.h:974
#define CS_NOCLOSE
Definition: winuser.h:662

Referenced by NtUserGetTitleBarInfo().

◆ IntHiliteMenuItem()

BOOL FASTCALL IntHiliteMenuItem ( PWND  WindowObject,
PMENU  MenuObject,
UINT  uItemHilite,
UINT  uHilite 
)

Definition at line 4804 of file menu.c.

4808{
4809 PITEM MenuItem;
4810 UINT uItem = uItemHilite;
4811
4812 if (!(MenuItem = MENU_FindItem( &MenuObject, &uItem, uHilite ))) return TRUE;
4813
4814 if (uHilite & MF_HILITE)
4815 {
4816 MenuItem->fState |= MF_HILITE;
4817 }
4818 else
4819 {
4820 MenuItem->fState &= ~MF_HILITE;
4821 }
4822 if (MenuObject->iItem == uItemHilite) return TRUE;
4823 MENU_HideSubPopups( WindowObject, MenuObject, FALSE, 0 );
4824 MENU_SelectItem( WindowObject, MenuObject, uItemHilite, TRUE, 0 );
4825
4826 return TRUE; // Always returns true!!!!
4827}
static void FASTCALL MENU_HideSubPopups(PWND pWndOwner, PMENU Menu, BOOL SendMenuSelect, UINT wFlags)
Definition: menu.c:3267
static void FASTCALL MENU_SelectItem(PWND pwndOwner, PMENU menu, UINT wIndex, BOOL sendMenuSelect, PMENU topmenu)
Definition: menu.c:3144
#define MF_HILITE
Definition: winuser.h:205

Referenced by NtUserHiliteMenuItem().

◆ 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
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
#define MF_BYCOMMAND
Definition: winuser.h:202
#define NT_ASSERT
Definition: rtlfuncs.h:3327

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  ItemInfo,
BOOL  SetOrGet,
PUNICODE_STRING  lpstr 
)

Definition at line 5102 of file menu.c.

5109{
5110 PITEM MenuItem;
5111 BOOL Ret;
5112
5113 if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5114 {
5116 return FALSE;
5117 }
5118 if (SetOrGet)
5119 {
5120 Ret = IntSetMenuItemInfo(Menu, MenuItem, ItemInfo, lpstr);
5121 }
5122 else
5123 {
5124 Ret = IntGetMenuItemInfo(Menu, MenuItem, ItemInfo);
5125 }
5126 return Ret;
5127}
_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  pMenu,
UINT  nPos,
UINT  wFlags,
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 __inline PVOID DesktopHeapReAlloc(IN PDESKTOP Desktop, IN PVOID lpMem, IN SIZE_T Bytes)
Definition: desktop.h:226
WINBASEAPI _In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon_undoc.h:337

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

◆ IntSetMenu()

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

Definition at line 5485 of file menu.c.

5489{
5490 PMENU OldMenu, NewMenu = NULL;
5491
5492 if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
5493 {
5494 ERR("SetMenu: Window is a Child 0x%p!\n",UserHMGetHandle(Wnd));
5496 return FALSE;
5497 }
5498
5499 *Changed = (UlongToHandle(Wnd->IDMenu) != Menu);
5500 if (! *Changed)
5501 {
5502 return TRUE;
5503 }
5504
5505 if (Wnd->IDMenu)
5506 {
5507 OldMenu = IntGetMenuObject(UlongToHandle(Wnd->IDMenu));
5508 ASSERT(NULL == OldMenu || OldMenu->hWnd == UserHMGetHandle(Wnd));
5509 }
5510 else
5511 {
5512 OldMenu = NULL;
5513 }
5514
5515 if (NULL != Menu)
5516 {
5517 NewMenu = IntGetMenuObject(Menu);
5518 if (NULL == NewMenu)
5519 {
5520 if (NULL != OldMenu)
5521 {
5522 IntReleaseMenuObject(OldMenu);
5523 }
5525 return FALSE;
5526 }
5527 if (NULL != NewMenu->hWnd)
5528 {
5529 /* Can't use the same menu for two windows */
5530 if (NULL != OldMenu)
5531 {
5532 IntReleaseMenuObject(OldMenu);
5533 }
5535 return FALSE;
5536 }
5537
5538 }
5539
5540 Wnd->IDMenu = (UINT_PTR) Menu;
5541 if (NULL != NewMenu)
5542 {
5543 NewMenu->hWnd = UserHMGetHandle(Wnd);
5544 IntReleaseMenuObject(NewMenu);
5545 }
5546 if (NULL != OldMenu)
5547 {
5548 OldMenu->hWnd = NULL;
5549 IntReleaseMenuObject(OldMenu);
5550 }
5551
5552 return TRUE;
5553}
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WS_POPUP
Definition: pedump.c:616
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().

◆ IntSetMenuContextHelpId()

BOOL FASTCALL IntSetMenuContextHelpId ( PMENU  Menu,
DWORD  dwContextHelpId 
)

Definition at line 872 of file menu.c.

873{
874 Menu->dwContextHelpId = dwContextHelpId;
875 return TRUE;
876}

Referenced by NtUserSetMenuContextHelpId().

◆ IntSetMenuFlagRtoL()

BOOL FASTCALL IntSetMenuFlagRtoL ( PMENU  Menu)

Definition at line 864 of file menu.c.

865{
866 ERR("SetMenuFlagRtoL\n");
867 Menu->fFlags |= MNF_RTOL;
868 return TRUE;
869}
#define MNF_RTOL
Definition: ntuser.h:405

Referenced by NtUserSetMenuFlagRtoL().

◆ IntSetMenuInfo()

BOOL FASTCALL IntSetMenuInfo ( PMENU  Menu,
PROSMENUINFO  lpmi 
)

Definition at line 914 of file menu.c.

915{
916 if(lpmi->fMask & MIM_BACKGROUND)
917 Menu->hbrBack = lpmi->hbrBack;
918 if(lpmi->fMask & MIM_HELPID)
919 Menu->dwContextHelpId = lpmi->dwContextHelpID;
920 if(lpmi->fMask & MIM_MAXHEIGHT)
921 Menu->cyMax = lpmi->cyMax;
922 if(lpmi->fMask & MIM_MENUDATA)
923 Menu->dwMenuData = lpmi->dwMenuData;
924 if(lpmi->fMask & MIM_STYLE)
925 Menu->fFlags ^= (Menu->fFlags ^ lpmi->dwStyle) & MNS_STYLE_MASK;
926 if(lpmi->fMask & MIM_APPLYTOSUBMENUS)
927 {
928 int i;
929 PITEM item = Menu->rgItems;
930 for ( i = Menu->cItems; i; i--, item++)
931 {
932 if ( item->spSubMenu )
933 {
934 IntSetMenuInfo( item->spSubMenu, lpmi);
935 }
936 }
937 }
938 if (sizeof(MENUINFO) < lpmi->cbSize)
939 {
940 Menu->iItem = lpmi->iItem;
941 Menu->cyMenu = lpmi->cyMenu;
942 Menu->cxMenu = lpmi->cxMenu;
943 Menu->spwndNotify = lpmi->spwndNotify;
944 Menu->cxTextAlign = lpmi->cxTextAlign;
945 Menu->iTop = lpmi->iTop;
946 Menu->iMaxTop = lpmi->iMaxTop;
947 Menu->dwArrowsOn = lpmi->dwArrowsOn;
948
949 Menu->TimeToHide = lpmi->TimeToHide;
950 Menu->hWnd = lpmi->Wnd;
951 }
952 if ( lpmi->fMask & MIM_STYLE)
953 {
954 if (lpmi->dwStyle & MNS_AUTODISMISS) FIXME("MNS_AUTODISMISS unimplemented wine\n");
955 if (lpmi->dwStyle & MNS_DRAGDROP) FIXME("MNS_DRAGDROP unimplemented wine\n");
956 if (lpmi->dwStyle & MNS_MODELESS) FIXME("MNS_MODELESS unimplemented wine\n");
957 }
958 return TRUE;
959}
#define FIXME(fmt,...)
Definition: precomp.h:53
BOOL FASTCALL IntSetMenuInfo(PMENU Menu, PROSMENUINFO lpmi)
Definition: menu.c:914
#define MNS_MODELESS
Definition: winuser.h:767
#define MNS_DRAGDROP
Definition: winuser.h:768
#define MNS_AUTODISMISS
Definition: winuser.h:769

Referenced by IntSetMenuInfo(), and UserMenuInfo().

◆ 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 KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define MNF_SYSMENU
Definition: ntuser.h:410
static HBITMAP
Definition: button.c:44
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
DWORD_PTR hTaskWow
Definition: ntuser.h:218
ULONG cch
Definition: ntuser.h:379
uint32_t ULONG_PTR
Definition: typedefs.h:65
#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 HBMMENU_POPUP_MINIMIZE
Definition: winuser.h:2659
#define HBMMENU_CALLBACK
Definition: winuser.h:2649
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3304

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

◆ IntSetSystemMenu()

BOOL FASTCALL IntSetSystemMenu ( PWND  Window,
PMENU  Menu 
)

Definition at line 5452 of file menu.c.

5453{
5454 PMENU OldMenu;
5455
5456 if (!(Window->style & WS_SYSMENU)) return FALSE;
5457
5458 if (Window->SystemMenu)
5459 {
5460 OldMenu = UserGetMenuObject(Window->SystemMenu);
5461 if (OldMenu)
5462 {
5463 OldMenu->fFlags &= ~MNF_SYSMENU;
5464 IntDestroyMenuObject(OldMenu, TRUE);
5465 }
5466 }
5467
5468 OldMenu = MENU_GetSystemMenu(Window, Menu);
5469 if (OldMenu)
5470 { // Use spmenuSys too!
5471 Window->SystemMenu = UserHMGetHandle(OldMenu);
5472 }
5473 else
5474 Window->SystemMenu = NULL;
5475
5476 if (Menu && Window != Menu->spwndNotify)
5477 {
5478 Menu->spwndNotify = Window;
5479 }
5480
5481 return TRUE;
5482}

Referenced by NtUserSetSystemMenu().

◆ IntTrackPopupMenuEx()

BOOL FASTCALL IntTrackPopupMenuEx ( _Inout_ PMENU  menu,
_In_ UINT  wFlags,
_In_ INT  x,
_In_ INT  y,
_In_ PWND  pWnd,
_In_opt_ const TPMPARAMS lpTpm 
)

Definition at line 4575 of file menu.c.

4582{
4583 BOOL ret = FALSE;
4585
4586 if (lpTpm && lpTpm->cbSize != sizeof(*lpTpm))
4587 {
4588 ERR("Invalid TPMPARAMS size: got %u, expected %zu\n", lpTpm->cbSize, sizeof(*lpTpm));
4590 return FALSE;
4591 }
4592
4593 if (pti != pWnd->head.pti)
4594 {
4595 ERR("Must be the same pti!\n");
4596 return ret;
4597 }
4598
4599 TRACE("hmenu %p flags %04x (%d,%d) hwnd %p lpTpm %p \n", //rect %s\n",
4600 UserHMGetHandle(menu), wFlags, x, y, UserHMGetHandle(pWnd), lpTpm); //,
4601 //lpTpm ? wine_dbgstr_rect( &lpTpm->rcExclude) : "-" );
4602
4603 if (menu->hWnd && IntIsWindow(menu->hWnd))
4604 {
4606 return FALSE;
4607 }
4608
4609 if (MENU_InitPopup( pWnd, menu, wFlags ))
4610 {
4611 MENU_InitTracking(pWnd, menu, TRUE, wFlags);
4612
4613 /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
4614 if (!(wFlags & TPM_NONOTIFY))
4615 {
4617 }
4618
4619 if (menu->fFlags & MNF_SYSMENU)
4620 MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
4621
4622 if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y, lpTpm ? &lpTpm->rcExclude : NULL))
4623 ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd);
4624 else
4625 {
4627 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4628 co_UserSetCapture(NULL); /* release the capture */
4629 }
4630
4632
4633 if (menu->hWnd)
4634 {
4635 PWND pwndM = ValidateHwndNoErr( menu->hWnd );
4636 if (pwndM) // wine hack around this with their destroy function.
4637 {
4638 if (!(pWnd->state & WNDS_DESTROYED))
4639 co_UserDestroyWindow( pwndM ); // Fix wrong error return.
4640 }
4641 menu->hWnd = 0;
4642
4643 if (!(wFlags & TPM_NONOTIFY))
4644 {
4645 co_IntSendMessage( UserHMGetHandle(pWnd), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(menu),
4646 MAKELPARAM(0, IS_SYSTEM_MENU(menu) ? MF_SYSMENU : 0));
4647 }
4648 }
4649 }
4650 return ret;
4651}
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1460
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define WNDS_DESTROYED
Definition: ntuser.h:636
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3608
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2507
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2870
#define IS_SYSTEM_MENU(MenuInfo)
Definition: menu.c:60
static BOOL MENU_InitPopup(PWND pWndOwner, PMENU menu, UINT flags)
Definition: menu.c:2781
static BOOL FASTCALL MENU_ExitTracking(PWND pWnd, BOOL bPopup, UINT wFlags)
Definition: menu.c:4464
#define TPM_POPUPMENU
Definition: menu.c:90
static BOOL FASTCALL MENU_ShowPopup(PWND pwndOwner, PMENU menu, UINT id, UINT flags, INT x, INT y, const RECT *pExclude)
Definition: menu.c:2939
void FASTCALL MENU_InitSysMenuPopup(PMENU menu, DWORD style, DWORD clsStyle, LONG HitTest)
Definition: menu.c:1362
static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
Definition: menu.c:4050
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4404
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1495
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:178
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
#define MAKELPARAM(l, h)
Definition: winuser.h:4084
#define MF_SYSMENU
Definition: winuser.h:141
#define WM_INITMENUPOPUP
Definition: winuser.h:1765
#define HTSYSMENU
Definition: winuser.h:2496

Referenced by co_UserTrackSystemMenu(), IntDefWindowProc(), and NtUserTrackPopupMenuEx().

◆ MENU_AdjustMenuItemRect()

VOID FASTCALL MENU_AdjustMenuItemRect ( PMENU  menu,
PRECTL  rect 
)

Definition at line 1462 of file menu.c.

1463{
1464 if (menu->dwArrowsOn)
1465 {
1466 UINT arrow_bitmap_height;
1467 arrow_bitmap_height = gpsi->oembmi[OBI_UPARROW].cy;
1468 rect->top += arrow_bitmap_height - menu->iTop;
1469 rect->bottom += arrow_bitmap_height - menu->iTop;
1470 }
1471}
PSERVERINFO gpsi
Definition: imm.c:18
@ OBI_UPARROW
Definition: ntuser.h:967
& rect
Definition: startmenu.cpp:1413

Referenced by MENU_DrawMenuItem(), MENU_FindItemByCoords(), MENU_ShowSubPopup(), and NtUserMenuItemFromPoint().

◆ MENU_ButtonDown()

static BOOL FASTCALL MENU_ButtonDown ( MTRACKER pmt,
PMENU  PtMenu,
UINT  Flags 
)
static

Definition at line 3558 of file menu.c.

3559{
3560 TRACE("%x PtMenu=%p\n", pmt, PtMenu);
3561
3562 if (PtMenu)
3563 {
3564 UINT id = 0;
3565 PITEM item;
3566
3567 // Special check for the icon system menu
3568 if (IS_SYSTEM_MENU(PtMenu) && !(PtMenu->fFlags & MNF_POPUP))
3569 {
3570 item = PtMenu->rgItems;
3571 }
3572 else
3573 {
3574 item = MENU_FindItemByCoords( PtMenu, pmt->Pt, &id );
3575 }
3576
3577 if (item)
3578 {
3579 if (PtMenu->iItem != id)
3580 MENU_SwitchTracking(pmt, PtMenu, id, Flags);
3581
3582 /* If the popup menu is not already "popped" */
3583 if (!(item->fState & MF_MOUSESELECT))
3584 {
3585 pmt->CurrentMenu = MENU_ShowSubPopup(pmt->OwnerWnd, PtMenu, FALSE, Flags);
3586 }
3587
3588 return TRUE;
3589 }
3590 /* Else the click was on the menu bar, finish the tracking */
3591 }
3592 return FALSE;
3593}
PMENU CurrentMenu
Definition: menu.c:81
PWND OwnerWnd
Definition: menu.c:83
POINT Pt
Definition: menu.c:84
static PMENU FASTCALL MENU_ShowSubPopup(PWND WndOwner, PMENU Menu, BOOL SelectFirst, UINT Flags)
Definition: menu.c:3321
static void FASTCALL MENU_SwitchTracking(MTRACKER *pmt, PMENU PtMenu, UINT Index, UINT wFlags)
Definition: menu.c:3533
#define MF_MOUSESELECT
Definition: winuser.h:145
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by MENU_TrackMenu().

◆ MENU_ButtonUp()

static INT FASTCALL MENU_ButtonUp ( MTRACKER pmt,
PMENU  PtMenu,
UINT  Flags 
)
static

Definition at line 3603 of file menu.c.

3604{
3605 TRACE("%p pmenu=%x\n", pmt, PtMenu);
3606
3607 if (PtMenu)
3608 {
3609 UINT Id = 0;
3610 ITEM *item;
3611
3612 // Special check for the icon system menu
3613 if (IS_SYSTEM_MENU(PtMenu) && !(PtMenu->fFlags & MNF_POPUP))
3614 {
3615 item = PtMenu->rgItems;
3616 }
3617 else
3618 {
3619 item = MENU_FindItemByCoords( PtMenu, pmt->Pt, &Id );
3620 }
3621
3622 if (item && ( PtMenu->iItem == Id))
3623 {
3624 if (!(item->spSubMenu))
3625 {
3626 INT ExecutedMenuId = MENU_ExecFocusedItem( pmt, PtMenu, Flags);
3627 if (ExecutedMenuId == -1 || ExecutedMenuId == -2) return -1;
3628 return ExecutedMenuId;
3629 }
3630
3631 /* If we are dealing with the menu bar */
3632 /* and this is a click on an already "popped" item: */
3633 /* Stop the menu tracking and close the opened submenus */
3634 if (pmt->TopMenu == PtMenu && PtMenu->TimeToHide)
3635 {
3636 return 0;
3637 }
3638 }
3639 if ( IntGetMenu(PtMenu->hWnd) == PtMenu )
3640 {
3641 PtMenu->TimeToHide = TRUE;
3642 }
3643 }
3644 return -1;
3645}
DWORD Id
PMENU TopMenu
Definition: menu.c:82
static INT FASTCALL MENU_ExecFocusedItem(MTRACKER *pmt, PMENU Menu, UINT Flags)
Definition: menu.c:3478
PMENU WINAPI IntGetMenu(HWND hWnd)
Definition: menu.c:248

Referenced by MENU_TrackMenu().

◆ MENU_CalcItemSize()

static void FASTCALL MENU_CalcItemSize ( HDC  hdc,
PITEM  lpitem,
PMENU  Menu,
PWND  pwndOwner,
INT  orgX,
INT  orgY,
BOOL  menuBar,
BOOL  textandbmp 
)
static

Definition at line 1825 of file menu.c.

1827{
1828 WCHAR *p;
1829 UINT check_bitmap_width = UserGetSystemMetrics( SM_CXMENUCHECK );
1830 UINT arrow_bitmap_width;
1831 RECT Rect;
1832 INT itemheight = 0;
1833
1834 TRACE("dc=%x owner=%x (%d,%d)\n", hdc, pwndOwner, orgX, orgY);
1835
1836 arrow_bitmap_width = gpsi->oembmi[OBI_MNARROW].cx;
1837
1839
1840 RECTL_vSetRect( &Rect, orgX, orgY, orgX, orgY );
1841
1842 if (lpitem->fType & MF_OWNERDRAW)
1843 {
1845 mis.CtlType = ODT_MENU;
1846 mis.CtlID = 0;
1847 mis.itemID = lpitem->wID;
1848 mis.itemData = lpitem->dwItemData;
1850 mis.itemWidth = 0;
1851 co_IntSendMessage( UserHMGetHandle(pwndOwner), WM_MEASUREITEM, 0, (LPARAM)&mis );
1852 /* Tests reveal that Windows ( Win95 thru WinXP) adds twice the average
1853 * width of a menufont character to the width of an owner-drawn menu.
1854 */
1855 Rect.right += mis.itemWidth + 2 * MenuCharSize.cx;
1856 if (menuBar) {
1857 /* under at least win95 you seem to be given a standard
1858 height for the menu and the height value is ignored */
1860 } else
1861 Rect.bottom += mis.itemHeight;
1862 // Or this,
1863 //lpitem->cxBmp = mis.itemWidth;
1864 //lpitem->cyBmp = mis.itemHeight;
1865 TRACE("MF_OWNERDRAW Height %d Width %d\n",mis.itemHeight,mis.itemWidth);
1866 TRACE("MF_OWNERDRAW id=%04lx size=%dx%d cx %d cy %d\n",
1867 lpitem->wID, Rect.right-Rect.left,
1868 Rect.bottom-Rect.top, MenuCharSize.cx, MenuCharSize.cy);
1869
1870 lpitem->xItem = Rect.left;
1871 lpitem->yItem = Rect.top;
1872 lpitem->cxItem = Rect.right;
1873 lpitem->cyItem = Rect.bottom;
1874
1875 return;
1876 }
1877
1878 lpitem->xItem = orgX;
1879 lpitem->yItem = orgY;
1880 lpitem->cxItem = orgX;
1881 lpitem->cyItem = orgY;
1882
1883 if (lpitem->fType & MF_SEPARATOR)
1884 {
1885 lpitem->cyItem += UserGetSystemMetrics( SM_CYMENUSIZE)/2;//SEPARATOR_HEIGHT;
1886 if( !menuBar)
1887 lpitem->cxItem += arrow_bitmap_width + MenuCharSize.cx;
1888 return;
1889 }
1890
1891 lpitem->dxTab = 0;
1892
1893 if (lpitem->hbmp)
1894 {
1895 SIZE size;
1896
1897 if (!menuBar) {
1898 MENU_GetBitmapItemSize(lpitem, &size, pwndOwner );
1899 /* Keep the size of the bitmap in callback mode to be able
1900 * to draw it correctly */
1901 lpitem->cxBmp = size.cx;
1902 lpitem->cyBmp = size.cy;
1903 Menu->cxTextAlign = max(Menu->cxTextAlign, size.cx);
1904 lpitem->cxItem += size.cx + 2;
1905 itemheight = size.cy + 2;
1906
1907 if( !((Menu->fFlags & MNS_STYLE_MASK) & MNS_NOCHECK))
1908 lpitem->cxItem += 2 * check_bitmap_width;
1909 lpitem->cxItem += 4 + MenuCharSize.cx;
1910 lpitem->dxTab = lpitem->cxItem;
1911 lpitem->cxItem += arrow_bitmap_width;
1912 } else /* hbmpItem & MenuBar */ {
1913 MENU_GetBitmapItemSize(lpitem, &size, pwndOwner );
1914 lpitem->cxItem += size.cx;
1915 if( lpitem->Xlpstr) lpitem->cxItem += 2;
1916 itemheight = size.cy;
1917
1918 /* Special case: Minimize button doesn't have a space behind it. */
1919 if (lpitem->hbmp == (HBITMAP)HBMMENU_MBAR_MINIMIZE ||
1921 lpitem->cxItem -= 1;
1922 }
1923 }
1924 else if (!menuBar) {
1925 if( !((Menu->fFlags & MNS_STYLE_MASK) & MNS_NOCHECK))
1926 lpitem->cxItem += check_bitmap_width;
1927 lpitem->cxItem += 4 + MenuCharSize.cx;
1928 lpitem->dxTab = lpitem->cxItem;
1929 lpitem->cxItem += arrow_bitmap_width;
1930 }
1931
1932 /* it must be a text item - unless it's the system menu */
1933 if (!(lpitem->fType & MF_SYSMENU) && lpitem->Xlpstr) {
1934 HFONT hfontOld = NULL;
1935 RECT rc;// = lpitem->Rect;
1936 LONG txtheight, txtwidth;
1937
1938 rc.left = lpitem->xItem;
1939 rc.top = lpitem->yItem;
1940 rc.right = lpitem->cxItem; // Do this for now......
1941 rc.bottom = lpitem->cyItem;
1942
1943 if ( lpitem->fState & MFS_DEFAULT ) {
1944 hfontOld = NtGdiSelectFont( hdc, ghMenuFontBold );
1945 }
1946 if (menuBar) {
1947 txtheight = DrawTextW( hdc, lpitem->Xlpstr, -1, &rc, DT_SINGLELINE|DT_CALCRECT);
1948
1949 lpitem->cxItem += rc.right - rc.left;
1950 itemheight = max( max( itemheight, txtheight), UserGetSystemMetrics( SM_CYMENU) - 1);
1951
1952 lpitem->cxItem += 2 * MenuCharSize.cx;
1953 } else {
1954 if ((p = wcschr( lpitem->Xlpstr, '\t' )) != NULL) {
1955 RECT tmprc = rc;
1956 LONG tmpheight;
1957 int n = (int)( p - lpitem->Xlpstr);
1958 /* Item contains a tab (only meaningful in popup menus) */
1959 /* get text size before the tab */
1960 txtheight = DrawTextW( hdc, lpitem->Xlpstr, n, &rc,
1962 txtwidth = rc.right - rc.left;
1963 p += 1; /* advance past the Tab */
1964 /* get text size after the tab */
1965 tmpheight = DrawTextW( hdc, p, -1, &tmprc,
1967 lpitem->dxTab += txtwidth;
1968 txtheight = max( txtheight, tmpheight);
1969 txtwidth += MenuCharSize.cx + /* space for the tab */
1970 tmprc.right - tmprc.left; /* space for the short cut */
1971 } else {
1972 txtheight = DrawTextW( hdc, lpitem->Xlpstr, -1, &rc,
1974 txtwidth = rc.right - rc.left;
1975 lpitem->dxTab += txtwidth;
1976 }
1977 lpitem->cxItem += 2 + txtwidth;
1978 itemheight = max( itemheight,
1979 max( txtheight + 2, MenuCharSize.cy + 4));
1980 }
1981 if (hfontOld)
1982 {
1983 NtGdiSelectFont (hdc, hfontOld);
1984 }
1985 } else if( menuBar) {
1986 itemheight = max( itemheight, UserGetSystemMetrics(SM_CYMENU)-1);
1987 }
1988 lpitem->cyItem += itemheight;
1989 TRACE("(%ld,%ld)-(%ld,%ld)\n", lpitem->xItem, lpitem->yItem, lpitem->cxItem, lpitem->cyItem);
1990}
#define wcschr
Definition: compat.h:17
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat p
Definition: glext.h:8902
@ OBI_MNARROW
Definition: ntuser.h:971
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
ULONG_PTR itemData
Definition: winuser.h:3722
#define max(a, b)
Definition: svc.c:63
#define HIWORD(l)
Definition: typedefs.h:247
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
static SIZE MenuCharSize
Definition: menu.c:18
static void FASTCALL MENU_GetBitmapItemSize(PITEM lpitem, SIZE *size, PWND WndOwner)
Definition: menu.c:1588
HFONT ghMenuFontBold
Definition: menu.c:17
LONG IntGetDialogBaseUnits(VOID)
Definition: menu.c:1800
LONG_PTR LPARAM
Definition: windef.h:208
#define SM_CXMENUCHECK
Definition: winuser.h:1042
#define HBMMENU_MBAR_MINIMIZE
Definition: winuser.h:2652
#define DT_SINGLELINE
Definition: winuser.h:540
#define HBMMENU_MBAR_MINIMIZE_D
Definition: winuser.h:2655
#define MF_SEPARATOR
Definition: winuser.h:137
#define WM_MEASUREITEM
Definition: winuser.h:1665
#define MNS_NOCHECK
Definition: winuser.h:766
#define SM_CYMENUSIZE
Definition: winuser.h:1029
#define DT_CALCRECT
Definition: winuser.h:526
#define MF_OWNERDRAW
Definition: winuser.h:135
#define ODT_MENU
Definition: winuser.h:2556

Referenced by MENU_MenuBarCalcSize(), and MENU_PopupMenuCalcSize().

◆ MENU_depth()

int FASTCALL MENU_depth ( PMENU  pmenu,
int  depth 
)

Definition at line 404 of file menu.c.

405{
406 UINT i;
407 ITEM *item;
408 int subdepth;
409
410 if (!pmenu) return depth;
411
412 depth++;
413 if( depth > MAXMENUDEPTH) return depth;
414 item = pmenu->rgItems;
415 subdepth = depth;
416 for( i = 0; i < pmenu->cItems && subdepth <= MAXMENUDEPTH; i++, item++)
417 {
418 if( item->spSubMenu)//VerifyMenu(item->spSubMenu))
419 {
420 int bdepth = MENU_depth( item->spSubMenu, depth);
421 if( bdepth > subdepth) subdepth = bdepth;
422 }
423 if( subdepth > MAXMENUDEPTH)
424 TRACE("<- hmenu %p\n", item->spSubMenu);
425 }
426 return subdepth;
427}
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546

Referenced by IntSetMenuItemInfo(), and MENU_depth().

◆ MENU_DoNextMenu()

static LRESULT FASTCALL MENU_DoNextMenu ( MTRACKER pmt,
UINT  Vk,
UINT  wFlags 
)
static

Definition at line 3735 of file menu.c.

3736{
3737 BOOL atEnd = FALSE;
3738
3739 /* When skipping left, we need to do something special after the
3740 first menu. */
3741 if (Vk == VK_LEFT && pmt->TopMenu->iItem == 0)
3742 {
3743 atEnd = TRUE;
3744 }
3745 /* When skipping right, for the non-system menu, we need to
3746 handle the last non-special menu item (ie skip any window
3747 icons such as MDI maximize, restore or close) */
3748 else if ((Vk == VK_RIGHT) && !IS_SYSTEM_MENU(pmt->TopMenu))
3749 {
3750 UINT i = pmt->TopMenu->iItem + 1;
3751 while (i < pmt->TopMenu->cItems) {
3752 if ((pmt->TopMenu->rgItems[i].wID >= SC_SIZE &&
3753 pmt->TopMenu->rgItems[i].wID <= SC_RESTORE)) {
3754 i++;
3755 } else break;
3756 }
3757 if (i == pmt->TopMenu->cItems) {
3758 atEnd = TRUE;
3759 }
3760 }
3761 /* When skipping right, we need to cater for the system menu */
3762 else if ((Vk == VK_RIGHT) && IS_SYSTEM_MENU(pmt->TopMenu))
3763 {
3764 if (pmt->TopMenu->iItem == (pmt->TopMenu->cItems - 1)) {
3765 atEnd = TRUE;
3766 }
3767 }
3768
3769 if ( atEnd )
3770 {
3771 MDINEXTMENU NextMenu;
3772 PMENU MenuTmp;
3773 PWND pwndTemp;
3774 HMENU hNewMenu;
3775 HWND hNewWnd;
3776 UINT Id = 0;
3777
3778 MenuTmp = (IS_SYSTEM_MENU(pmt->TopMenu)) ? co_IntGetSubMenu(pmt->TopMenu, 0) : pmt->TopMenu;
3779 NextMenu.hmenuIn = UserHMGetHandle(MenuTmp);
3780 NextMenu.hmenuNext = NULL;
3781 NextMenu.hwndNext = NULL;
3783
3784 TRACE("%p [%p] -> %p [%p]\n",
3785 pmt->CurrentMenu, pmt->OwnerWnd, NextMenu.hmenuNext, NextMenu.hwndNext );
3786
3787 if (NULL == NextMenu.hmenuNext || NULL == NextMenu.hwndNext)
3788 {
3789 hNewWnd = UserHMGetHandle(pmt->OwnerWnd);
3790 if (IS_SYSTEM_MENU(pmt->TopMenu))
3791 {
3792 /* switch to the menu bar */
3793
3794 if (pmt->OwnerWnd->style & WS_CHILD || !(MenuTmp = IntGetMenu(hNewWnd))) return FALSE;
3795
3796 if (Vk == VK_LEFT)
3797 {
3798 Id = MenuTmp->cItems - 1;
3799
3800 /* Skip backwards over any system predefined icons,
3801 eg. MDI close, restore etc icons */
3802 while ((Id > 0) &&
3803 (MenuTmp->rgItems[Id].wID >= SC_SIZE &&
3804 MenuTmp->rgItems[Id].wID <= SC_RESTORE)) Id--;
3805
3806 }
3807 hNewMenu = UserHMGetHandle(MenuTmp);
3808 }
3809 else if (pmt->OwnerWnd->style & WS_SYSMENU)
3810 {
3811 /* switch to the system menu */
3812 MenuTmp = get_win_sys_menu(hNewWnd);
3813 if (MenuTmp) hNewMenu = UserHMGetHandle(MenuTmp);
3814 else hNewMenu = NULL;
3815 }
3816 else
3817 return FALSE;
3818 }
3819 else /* application returned a new menu to switch to */
3820 {
3821 hNewMenu = NextMenu.hmenuNext;
3822 hNewWnd = NextMenu.hwndNext;
3823
3824 if ((MenuTmp = UserGetMenuObject(hNewMenu)) && (pwndTemp = ValidateHwndNoErr(hNewWnd)))
3825 {
3826 if ( pwndTemp->style & WS_SYSMENU && (get_win_sys_menu(hNewWnd) == MenuTmp) )
3827 {
3828 /* get the real system menu */
3829 MenuTmp = get_win_sys_menu(hNewWnd);
3830 hNewMenu = UserHMGetHandle(MenuTmp);
3831 }
3832 else if (pwndTemp->style & WS_CHILD || IntGetMenu(hNewWnd) != MenuTmp)
3833 {
3834 /* FIXME: Not sure what to do here;
3835 * perhaps try to track NewMenu as a popup? */
3836
3837 WARN(" -- got confused.\n");
3838 return FALSE;
3839 }
3840 }
3841 else return FALSE;
3842 }
3843
3844 if (hNewMenu != UserHMGetHandle(pmt->TopMenu))
3845 {
3847
3848 if (pmt->CurrentMenu != pmt->TopMenu)
3850 }
3851
3852 if (hNewWnd != UserHMGetHandle(pmt->OwnerWnd))
3853 {
3855 pmt->OwnerWnd = ValidateHwndNoErr(hNewWnd);
3858 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
3860 pti->MessageQueue->QF_flags |= QF_CAPTURELOCKED;
3861 }
3862
3863 pmt->TopMenu = pmt->CurrentMenu = UserGetMenuObject(hNewMenu); /* all subpopups are hidden */
3864 MENU_SelectItem(pmt->OwnerWnd, pmt->TopMenu, Id, TRUE, 0);
3865
3866 return TRUE;
3867 }
3868 return FALSE;
3869}
#define WARN(fmt,...)
Definition: precomp.h:61
#define QF_CAPTURELOCKED
Definition: msgqueue.h:111
HMENU hmenuNext
Definition: winuser.h:3712
HMENU hmenuIn
Definition: winuser.h:3711
PMENU get_win_sys_menu(HWND hwnd)
Definition: menu.c:258
PMENU FASTCALL co_IntGetSubMenu(PMENU pMenu, int nPos)
Definition: menu.c:1348
#define WM_NEXTMENU
Definition: winuser.h:1825
#define VK_LEFT
Definition: winuser.h:2243
#define VK_RIGHT
Definition: winuser.h:2245

Referenced by MENU_KeyLeft(), and MENU_KeyRight().

◆ MENU_DrawBitmapItem()

static void FASTCALL MENU_DrawBitmapItem ( HDC  hdc,
PITEM  lpitem,
const RECT rect,
PMENU  Menu,
PWND  WndOwner,
UINT  odaction,
BOOL  MenuBar 
)
static

Definition at line 1653 of file menu.c.

1655{
1656 BITMAP bm;
1657 DWORD rop;
1658 HDC hdcMem;
1659 HBITMAP bmp;
1660 int w = rect->right - rect->left;
1661 int h = rect->bottom - rect->top;
1662 int bmp_xoffset = 0;
1663 int left, top;
1664 BOOL flat_menu;
1665 HBITMAP hbmToDraw = lpitem->hbmp;
1666 bmp = hbmToDraw;
1667
1668 UserSystemParametersInfo(SPI_GETFLATMENU, 0, &flat_menu, 0);
1669
1670 /* Check if there is a magic menu item associated with this item */
1671 if (IS_MAGIC_BITMAP(hbmToDraw))
1672 {
1673 UINT flags = 0;
1674 RECT r;
1675
1676 r = *rect;
1677 switch ((INT_PTR)hbmToDraw)
1678 {
1679 case (INT_PTR)HBMMENU_SYSTEM:
1680 if (lpitem->dwItemData)
1681 {
1682 if (ValidateHwndNoErr((HWND)lpitem->dwItemData))
1683 {
1684 ERR("Get Item Data from this Window!!!\n");
1685 }
1686
1687 ERR("Draw Bitmap\n");
1688 bmp = (HBITMAP)lpitem->dwItemData;
1689 if (!GreGetObject( bmp, sizeof(bm), &bm )) return;
1690 }
1691 else
1692 {
1693 PCURICON_OBJECT pIcon = NULL;
1694 //if (!BmpSysMenu) BmpSysMenu = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE));
1695 //bmp = BmpSysMenu;
1696 //if (! GreGetObject(bmp, sizeof(bm), &bm)) return;
1697 /* only use right half of the bitmap */
1698 //bmp_xoffset = bm.bmWidth / 2;
1699 //bm.bmWidth -= bmp_xoffset;
1700 if (WndOwner)
1701 {
1702 pIcon = NC_IconForWindow(WndOwner);
1703 // FIXME: NC_IconForWindow should reference it for us */
1704 if (pIcon) UserReferenceObject(pIcon);
1705 }
1706 ERR("Draw ICON\n");
1707 if (pIcon)
1708 {
1711 LONG x = rect->left - cx/2 + 1 + (rect->bottom - rect->top)/2; // this is really what Window does
1712 LONG y = (rect->top + rect->bottom)/2 - cy/2; // center
1713 UserDrawIconEx(hdc, x, y, pIcon, cx, cy, 0, NULL, DI_NORMAL);
1714 UserDereferenceObject(pIcon);
1715 }
1716 return;
1717 }
1718 goto got_bitmap;
1721 break;
1723 r.right += 1;
1725 break;
1727 r.right += 1;
1729 break;
1732 break;
1735 break;
1737 {
1738 DRAWITEMSTRUCT drawItem;
1739 POINT origorg;
1740 drawItem.CtlType = ODT_MENU;
1741 drawItem.CtlID = 0;
1742 drawItem.itemID = lpitem->wID;
1743 drawItem.itemAction = odaction;
1744 drawItem.itemState = (lpitem->fState & MF_CHECKED)?ODS_CHECKED:0;
1745 drawItem.itemState |= (lpitem->fState & MF_DEFAULT)?ODS_DEFAULT:0;
1746 drawItem.itemState |= (lpitem->fState & MF_DISABLED)?ODS_DISABLED:0;
1747 drawItem.itemState |= (lpitem->fState & MF_GRAYED)?ODS_GRAYED|ODS_DISABLED:0;
1748 drawItem.itemState |= (lpitem->fState & MF_HILITE)?ODS_SELECTED:0;
1749 drawItem.itemState |= (!(Menu->fFlags & MNF_UNDERLINE))?ODS_NOACCEL:0;
1750 drawItem.itemState |= (Menu->fFlags & MNF_INACTIVE)?ODS_INACTIVE:0;
1751 drawItem.hwndItem = (HWND)UserHMGetHandle(Menu);
1752 drawItem.hDC = hdc;
1753 drawItem.rcItem = *rect;
1754 drawItem.itemData = lpitem->dwItemData;
1755 /* some applications make this assumption on the DC's origin */
1756 GreSetViewportOrgEx( hdc, lpitem->xItem, lpitem->yItem, &origorg);
1757 RECTL_vOffsetRect(&drawItem.rcItem, -(LONG)lpitem->xItem, -(LONG)lpitem->yItem);
1758 co_IntSendMessage( UserHMGetHandle(WndOwner), WM_DRAWITEM, 0, (LPARAM)&drawItem);
1759 GreSetViewportOrgEx( hdc, origorg.x, origorg.y, NULL);
1760 return;
1761 }
1762 break;
1763
1768 MENU_DrawPopupGlyph(hdc, &r, (INT_PTR)hbmToDraw, lpitem->fState & MF_GRAYED, lpitem->fState & MF_HILITE);
1769 return;
1770 }
1771 RECTL_vInflateRect(&r, -1, -1);
1772 if (lpitem->fState & MF_HILITE) flags |= DFCS_PUSHED;
1774 return;
1775 }
1776
1777 if (!bmp || !GreGetObject( bmp, sizeof(bm), &bm )) return;
1778
1779 got_bitmap:
1782 /* handle fontsize > bitmap_height */
1783 top = (h>bm.bmHeight) ? rect->top+(h-bm.bmHeight)/2 : rect->top;
1784 left=rect->left;
1785 rop=((lpitem->fState & MF_HILITE) && !IS_MAGIC_BITMAP(hbmToDraw)) ? NOTSRCCOPY : SRCCOPY;
1786 if ((lpitem->fState & MF_HILITE) && lpitem->hbmp)
1788 if (MenuBar &&
1789 !flat_menu &&
1790 (lpitem->fState & (MF_HILITE | MF_GRAYED)) == MF_HILITE)
1791 {
1792 ++left;
1793 ++top;
1794 }
1795 NtGdiBitBlt( hdc, left, top, w, h, hdcMem, bmp_xoffset, 0, rop , 0, 0);
1797}
COLORREF FASTCALL IntGdiSetBkColor(_In_ HDC hDC, _In_ COLORREF Color)
BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL)
Definition: dclife.c:892
HANDLE HWND
Definition: compat.h:19
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLbitfield flags
Definition: glext.h:7161
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define MNF_INACTIVE
Definition: ntuser.h:404
#define MNF_UNDERLINE
Definition: ntuser.h:403
if(dx< 0)
Definition: linetemp.h:194
BITMAP bmp
Definition: alphablend.c:62
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
BOOL FASTCALL GreSetViewportOrgEx(HDC hDC, int X, int Y, LPPOINT Point)
Definition: coord.c:915
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiBitBlt(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD rop4, _In_ DWORD crBackColor, _In_ FLONG fl)
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
Definition: bl.h:1331
ULONG_PTR itemData
Definition: winuser.h:3169
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int32_t INT_PTR
Definition: typedefs.h:64
HDC hdcMem
Definition: welcome.c:104
INT NTAPI GreGetObject(IN HGDIOBJ hobj, IN INT cbCount, OUT PVOID pvBuffer)
Definition: gdiobj.c:1270
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
Definition: cursoricon.c:1689
#define IS_MAGIC_BITMAP(id)
Definition: menu.c:63
static void FASTCALL MENU_DrawPopupGlyph(HDC dc, LPRECT r, INT_PTR popupMagic, BOOL inactive, BOOL hilite)
Definition: menu.c:1398
PCURICON_OBJECT FASTCALL NC_IconForWindow(PWND pWnd)
Definition: nonclient.c:736
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
#define DI_NORMAL
Definition: wingdi.h:72
#define SRCCOPY
Definition: wingdi.h:333
#define NOTSRCCOPY
Definition: wingdi.h:325
#define ODS_DISABLED
Definition: winuser.h:2566
#define ODS_SELECTED
Definition: winuser.h:2564
#define HBMMENU_SYSTEM
Definition: winuser.h:2650
#define HBMMENU_MBAR_RESTORE
Definition: winuser.h:2651
#define ODS_CHECKED
Definition: winuser.h:2567
#define HBMMENU_POPUP_RESTORE
Definition: winuser.h:2657
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_CAPTIONMIN
Definition: winuser.h:481
#define DFCS_CAPTIONCLOSE
Definition: winuser.h:480
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
#define DFCS_INACTIVE
Definition: winuser.h:502
#define SM_CYSMICON
Definition: winuser.h:1024
#define WM_DRAWITEM
Definition: winuser.h:1664
#define DFC_CAPTION
Definition: winuser.h:473
#define MF_DEFAULT
Definition: winuser.h:140
#define SM_CXSMICON
Definition: winuser.h:1023
#define HBMMENU_POPUP_CLOSE
Definition: winuser.h:2656
#define DFCS_CAPTIONRESTORE
Definition: winuser.h:483
#define HBMMENU_MBAR_CLOSE
Definition: winuser.h:2653
#define ODS_GRAYED
Definition: winuser.h:2565
#define HBMMENU_MBAR_CLOSE_D
Definition: winuser.h:2654
#define HBMMENU_POPUP_MAXIMIZE
Definition: winuser.h:2658
#define DFCS_PUSHED
Definition: winuser.h:503

Referenced by MENU_DrawMenuItem().

◆ 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}
DWORD WINAPI IntDrawMenuBarTemp(PWND pWnd, HDC hDC, LPRECT Rect, PMENU pMenu, HFONT Font)
Definition: menu.c:2685

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

◆ MENU_DrawMenuItem()

static void FASTCALL MENU_DrawMenuItem ( PWND  Wnd,
PMENU  Menu,
PWND  WndOwner,
HDC  hdc,
PITEM  lpitem,
UINT  Height,
BOOL  menuBar,
UINT  odaction 
)
static

Definition at line 2204 of file menu.c.

2206{
2207 RECT rect;
2208 PWCHAR Text;
2209 BOOL flat_menu = FALSE;
2210 int bkgnd;
2211 UINT arrow_bitmap_width = 0;
2212 //RECT bmprc;
2213
2214 if (!menuBar) {
2215 arrow_bitmap_width = gpsi->oembmi[OBI_MNARROW].cx;
2216 }
2217
2218 if (lpitem->fType & MF_SYSMENU)
2219 {
2220 if (!(Wnd->style & WS_MINIMIZE))
2221 {
2222 NC_GetInsideRect(Wnd, &rect);
2224 }
2225 return;
2226 }
2227
2228 UserSystemParametersInfo (SPI_GETFLATMENU, 0, &flat_menu, 0);
2229 bkgnd = (menuBar && flat_menu) ? COLOR_MENUBAR : COLOR_MENU;
2230
2231 /* Setup colors */
2232
2233 if (lpitem->fState & MF_HILITE)
2234 {
2235 if(menuBar && !flat_menu) {
2238 } else {
2239 if (lpitem->fState & MF_GRAYED)
2241 else
2244 }
2245 }
2246 else
2247 {
2248 if (lpitem->fState & MF_GRAYED)
2250 else
2252 IntGdiSetBkColor( hdc, IntGetSysColor( bkgnd ) );
2253 }
2254
2255 //TRACE("rect=%s\n", wine_dbgstr_rect( &lpitem->Rect));
2256 //rect = lpitem->Rect;
2257 rect.left = lpitem->xItem;
2258 rect.top = lpitem->yItem;
2259 rect.right = lpitem->cxItem; // Do this for now......
2260 rect.bottom = lpitem->cyItem;
2261
2263
2264 if (lpitem->fType & MF_OWNERDRAW)
2265 {
2266 /*
2267 ** Experimentation under Windows reveals that an owner-drawn
2268 ** menu is given the rectangle which includes the space it requested
2269 ** in its response to WM_MEASUREITEM _plus_ width for a checkmark
2270 ** and a popup-menu arrow. This is the value of lpitem->rect.
2271 ** Windows will leave all drawing to the application except for
2272 ** the popup-menu arrow. Windows always draws that itself, after
2273 ** the menu owner has finished drawing.
2274 */
2275 DRAWITEMSTRUCT dis;
2276 COLORREF old_bk, old_text;
2277
2278 dis.CtlType = ODT_MENU;
2279 dis.CtlID = 0;
2280 dis.itemID = lpitem->wID;
2281 dis.itemData = (DWORD)lpitem->dwItemData;
2282 dis.itemState = 0;
2283 if (lpitem->fState & MF_CHECKED) dis.itemState |= ODS_CHECKED;
2284 if (lpitem->fState & MF_DEFAULT) dis.itemState |= ODS_DEFAULT;
2285 if (lpitem->fState & MF_DISABLED) dis.itemState |= ODS_DISABLED;
2286 if (lpitem->fState & MF_GRAYED) dis.itemState |= ODS_GRAYED | ODS_DISABLED;
2287 if (lpitem->fState & MF_HILITE) dis.itemState |= ODS_SELECTED;
2288 if (!(Menu->fFlags & MNF_UNDERLINE)) dis.itemState |= ODS_NOACCEL;
2289 if (Menu->fFlags & MNF_INACTIVE) dis.itemState |= ODS_INACTIVE;
2290 dis.itemAction = odaction; /* ODA_DRAWENTIRE | ODA_SELECT | ODA_FOCUS; */
2291 dis.hwndItem = (HWND) UserHMGetHandle(Menu);
2292 dis.hDC = hdc;
2293 dis.rcItem = rect;
2294 TRACE("Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, "
2295 "hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", Wnd,
2296 dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem,
2297 dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
2298 dis.rcItem.bottom);
2299 TRACE("Ownerdraw: Width %d Height %d\n", dis.rcItem.right-dis.rcItem.left, dis.rcItem.bottom-dis.rcItem.top);
2300 old_bk = GreGetBkColor(hdc);
2301 old_text = GreGetTextColor(hdc);
2302 co_IntSendMessage(UserHMGetHandle(WndOwner), WM_DRAWITEM, 0, (LPARAM) &dis);
2303 IntGdiSetBkColor(hdc, old_bk);
2304 IntGdiSetTextColor(hdc, old_text);
2305 /* Draw the popup-menu arrow */
2306 if (!menuBar && lpitem->spSubMenu)
2307 {
2308 RECT rectTemp;
2309 RtlCopyMemory(&rectTemp, &rect, sizeof(RECT));
2310 rectTemp.left = rectTemp.right - UserGetSystemMetrics(SM_CXMENUCHECK);
2312 }
2313 return;
2314 }
2315
2316 if (menuBar && (lpitem->fType & MF_SEPARATOR)) return;
2317
2318 if (lpitem->fState & MF_HILITE)
2319 {
2320 if (flat_menu)
2321 {
2322 RECTL_vInflateRect (&rect, -1, -1);
2323 FillRect(hdc, &rect, IntGetSysColorBrush(COLOR_MENUHILIGHT));
2324 RECTL_vInflateRect (&rect, 1, 1);
2326 }
2327 else
2328 {
2329 if (menuBar)
2330 {
2333 }
2334 else
2335 {
2337 }
2338 }
2339 }
2340 else
2341 FillRect( hdc, &rect, IntGetSysColorBrush(bkgnd) );
2342
2344
2345 /* vertical separator */
2346 if (!menuBar && (lpitem->fType & MF_MENUBARBREAK))
2347 {
2348 HPEN oldPen;
2349 RECT rc = rect;
2350
2351 rc.left -= 3;//MENU_COL_SPACE / 2 + 1; == 3!!
2352 rc.top = 3;
2353 rc.bottom = Height - 3;
2354 if (flat_menu)
2355 {
2356 oldPen = NtGdiSelectPen( hdc, NtGdiGetStockObject(DC_PEN) );
2358 GreMoveTo( hdc, rc.left, rc.top, NULL );
2359 NtGdiLineTo( hdc, rc.left, rc.bottom );
2360 NtGdiSelectPen( hdc, oldPen );
2361 }
2362 else
2364 }
2365
2366 /* horizontal separator */
2367 if (lpitem->fType & MF_SEPARATOR)
2368 {
2369 HPEN oldPen;
2370 RECT rc = rect;
2371
2372 rc.left++;
2373 rc.right--;
2374 rc.top = (rc.top + rc.bottom) / 2 - 1;
2375 if (flat_menu)
2376 {
2377 oldPen = NtGdiSelectPen( hdc, NtGdiGetStockObject(DC_PEN) );
2379 GreMoveTo( hdc, rc.left, rc.top, NULL );
2380 NtGdiLineTo( hdc, rc.right, rc.top );
2381 NtGdiSelectPen( hdc, oldPen );
2382 }
2383 else
2384 DrawEdge (hdc, &rc, EDGE_ETCHED, BF_TOP);
2385 return;
2386 }
2387#if 0
2388 /* helper lines for debugging */
2389 /* This is a very good test tool when hacking menus! (JT) 07/16/2006 */
2393 GreMoveTo(hdc, rect.left, (rect.top + rect.bottom) / 2, NULL);
2394 NtGdiLineTo(hdc, rect.right, (rect.top + rect.bottom) / 2);
2395#endif
2396#if 0 // breaks mdi menu bar icons.
2397 if (lpitem->hbmp) {
2398 /* calculate the bitmap rectangle in coordinates relative
2399 * to the item rectangle */
2400 if( menuBar) {
2401 if( lpitem->hbmp == HBMMENU_CALLBACK)
2402 bmprc.left = 3;
2403 else
2404 bmprc.left = lpitem->Xlpstr ? MenuCharSize.cx : 0;
2405 }
2406 else if ((Menu->fFlags & MNS_STYLE_MASK) & MNS_NOCHECK)
2407 bmprc.left = 4;
2408 else if ((Menu->fFlags & MNS_STYLE_MASK) & MNS_CHECKORBMP)
2409 bmprc.left = 2;
2410 else
2411 bmprc.left = 4 + UserGetSystemMetrics(SM_CXMENUCHECK);
2412
2413 bmprc.right = bmprc.left + lpitem->cxBmp;
2414
2415 if( menuBar && !(lpitem->hbmp == HBMMENU_CALLBACK))
2416 bmprc.top = 0;
2417 else
2418 bmprc.top = (rect.bottom - rect.top - lpitem->cyBmp) / 2;
2419
2420 bmprc.bottom = bmprc.top + lpitem->cyBmp;
2421 }
2422#endif
2423 if (!menuBar)
2424 {
2425 HBITMAP bm;
2426 INT y = rect.top + rect.bottom;
2427 RECT rc = rect;
2428 BOOL checked = FALSE;
2429 UINT check_bitmap_width = UserGetSystemMetrics( SM_CXMENUCHECK );
2430 UINT check_bitmap_height = UserGetSystemMetrics( SM_CYMENUCHECK );
2431 /* Draw the check mark
2432 *
2433 * FIXME:
2434 * Custom checkmark bitmaps are monochrome but not always 1bpp.
2435 */
2436 if( !((Menu->fFlags & MNS_STYLE_MASK) & MNS_NOCHECK)) {
2437 bm = (lpitem->fState & MF_CHECKED) ? lpitem->hbmpChecked :
2438 lpitem->hbmpUnchecked;
2439 if (bm) /* we have a custom bitmap */
2440 {
2442
2444 NtGdiBitBlt( hdc, rc.left, (y - check_bitmap_height) / 2,
2445 check_bitmap_width, check_bitmap_height,
2446 hdcMem, 0, 0, SRCCOPY, 0,0);
2448 checked = TRUE;
2449 }
2450 else if (lpitem->fState & MF_CHECKED) /* standard bitmaps */
2451 {
2452 RECT r;
2453 r = rect;
2454 r.right = r.left + check_bitmap_width;
2456 (lpitem->fType & MFT_RADIOCHECK) ?
2458 checked = TRUE;
2459 }
2460 }
2461 if ( lpitem->hbmp )//&& !( checked && ((Menu->fFlags & MNS_STYLE_MASK) & MNS_CHECKORBMP)))
2462 {
2463 RECT bmpRect = rect;
2464 if (!((Menu->fFlags & MNS_STYLE_MASK) & MNS_CHECKORBMP) && !((Menu->fFlags & MNS_STYLE_MASK) & MNS_NOCHECK))
2465 bmpRect.left += check_bitmap_width + 2;
2466 if (!(checked && ((Menu->fFlags & MNS_STYLE_MASK) & MNS_CHECKORBMP)))
2467 {
2468 bmpRect.right = bmpRect.left + lpitem->cxBmp;
2469 MENU_DrawBitmapItem(hdc, lpitem, &bmpRect, Menu, WndOwner, odaction, menuBar);
2470 }
2471 }
2472 /* Draw the popup-menu arrow */
2473 if (lpitem->spSubMenu)
2474 {
2475 RECT rectTemp;
2476 RtlCopyMemory(&rectTemp, &rect, sizeof(RECT));
2477 rectTemp.left = rectTemp.right - check_bitmap_width;
2479 }
2480 rect.left += 4;
2481 if( !((Menu->fFlags & MNS_STYLE_MASK) & MNS_NOCHECK))
2482 rect.left += check_bitmap_width;
2483 rect.right -= arrow_bitmap_width;
2484 }
2485 else if( lpitem->hbmp)
2486 { /* Draw the bitmap */
2487 MENU_DrawBitmapItem(hdc, lpitem, &rect/*bmprc*/, Menu, WndOwner, odaction, menuBar);
2488 }
2489
2490 /* process text if present */
2491 if (lpitem->Xlpstr)
2492 {
2493 int i = 0;
2494 HFONT hfontOld = 0;
2495
2496 UINT uFormat = menuBar ?
2499
2500 if (((Menu->fFlags & MNS_STYLE_MASK) & MNS_CHECKORBMP))
2501 rect.left += max(0, (int)(Menu->cxTextAlign - UserGetSystemMetrics(SM_CXMENUCHECK)));
2502 else
2503 rect.left += Menu->cxTextAlign;
2504
2505 if ( lpitem->fState & MFS_DEFAULT )
2506 {
2507 hfontOld = NtGdiSelectFont(hdc, ghMenuFontBold);
2508 }
2509
2510 if (menuBar) {
2511 if( lpitem->hbmp)
2512 rect.left += lpitem->cxBmp;
2513 if( !(lpitem->hbmp == HBMMENU_CALLBACK))
2514 rect.left += MenuCharSize.cx;
2515 rect.right -= MenuCharSize.cx;
2516 }
2517
2518 Text = lpitem->Xlpstr;
2519 if(Text)
2520 {
2521 for (i = 0; Text[i]; i++)
2522 if (Text[i] == L'\t' || Text[i] == L'\b')
2523 break;
2524 }
2525
2526 if (menuBar &&
2527 !flat_menu &&
2528 (lpitem->fState & (MF_HILITE | MF_GRAYED)) == MF_HILITE)
2529 {
2530 RECTL_vOffsetRect(&rect, +1, +1);
2531 }
2532
2533 if (!menuBar)
2534 --rect.bottom;
2535
2536 if(lpitem->fState & MF_GRAYED)
2537 {
2538 if (!(lpitem->fState & MF_HILITE) )
2539 {
2540 ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
2542 DrawTextW( hdc, Text, i, &rect, uFormat );
2543 --rect.left; --rect.top; --rect.right; --rect.bottom;
2544 }
2546 }
2547 DrawTextW( hdc, Text, i, &rect, uFormat);
2548
2549 /* paint the shortcut text */
2550 if (!menuBar && L'\0' != Text[i]) /* There's a tab or flush-right char */
2551 {
2552 if (L'\t' == Text[i])
2553 {
2554 rect.left = lpitem->dxTab;
2555 uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
2556 }
2557 else
2558 {
2559 rect.right = lpitem->dxTab;
2560 uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE;
2561 }
2562
2563 if (lpitem->fState & MF_GRAYED)
2564 {
2565 if (!(lpitem->fState & MF_HILITE) )
2566 {
2567 ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
2569 DrawTextW( hdc, Text + i + 1, -1, &rect, uFormat);
2570 --rect.left; --rect.top; --rect.right; --rect.bottom;
2571 }
2573 }
2574 DrawTextW( hdc, Text + i + 1, -1, &rect, uFormat );
2575 }
2576
2577 if (!menuBar)
2578 ++rect.bottom;
2579
2580 if (menuBar &&
2581 !flat_menu &&
2582 (lpitem->fState & (MF_HILITE | MF_GRAYED)) == MF_HILITE)
2583 {
2584 RECTL_vOffsetRect(&rect, -1, -1);
2585 }
2586
2587 if (hfontOld)
2588 {
2589 NtGdiSelectFont (hdc, hfontOld);
2590 }
2591 }
2592}
char * Text
Definition: combotst.c:136
COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color)
Definition: dcutil.c:172
COLORREF FASTCALL GreGetBkColor(HDC)
Definition: dcutil.c:50
INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode)
Definition: dcutil.c:124
COLORREF FASTCALL GreGetTextColor(HDC)
Definition: dcutil.c:80
#define L(x)
Definition: resources.c:13
#define WS_MINIMIZE
Definition: pedump.c:622
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
BOOL FASTCALL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
Definition: draw.c:959
VOID FASTCALL MENU_AdjustMenuItemRect(PMENU menu, PRECTL rect)
Definition: menu.c:1462
static void FASTCALL MENU_DrawBitmapItem(HDC hdc, PITEM lpitem, const RECT *rect, PMENU Menu, PWND WndOwner, UINT odaction, BOOL MenuBar)
Definition: menu.c:1653
BOOL UserDrawSysMenuButton(PWND pWnd, HDC hDC, LPRECT Rect, BOOL Down)
Definition: nonclient.c:767
void FASTCALL NC_GetInsideRect(PWND Wnd, RECT *rect)
Definition: nonclient.c:71
DWORD COLORREF
Definition: windef.h:300
#define TRANSPARENT
Definition: wingdi.h:950
#define BLACK_BRUSH
Definition: wingdi.h:896
#define DFCS_MENUCHECK
Definition: winuser.h:486
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)
#define BDR_SUNKENOUTER
Definition: winuser.h:443
#define COLOR_GRAYTEXT
Definition: winuser.h:943
#define COLOR_WINDOWFRAME
Definition: winuser.h:930
#define DT_CENTER
Definition: winuser.h:527
#define MF_MENUBARBREAK
Definition: winuser.h:133
#define BF_LEFT
Definition: winuser.h:454
#define DFCS_MENUARROW
Definition: winuser.h:485
#define EDGE_ETCHED
Definition: winuser.h:452
#define MNS_CHECKORBMP
Definition: winuser.h:771
#define DT_LEFT
Definition: winuser.h:534
#define SM_CYMENUCHECK
Definition: winuser.h:1043
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define BF_TOP
Definition: winuser.h:455
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
#define COLOR_BTNSHADOW
Definition: winuser.h:941
#define DT_VCENTER
Definition: winuser.h:543
#define DT_RIGHT
Definition: winuser.h:538
#define COLOR_MENUTEXT
Definition: winuser.h:931
#define DFCS_MENUBULLET
Definition: winuser.h:487
#define COLOR_BTNHIGHLIGHT
Definition: winuser.h:946
#define BF_RECT
Definition: winuser.h:462

Referenced by IntDrawMenuBarTemp(), MENU_DrawPopupMenu(), MENU_SelectItem(), and MENU_ShowSubPopup().

◆ MENU_DrawPopupGlyph()

static void FASTCALL MENU_DrawPopupGlyph ( HDC  dc,
LPRECT  r,
INT_PTR  popupMagic,
BOOL  inactive,
BOOL  hilite 
)
static

Definition at line 1398 of file menu.c.

1399{
1400 LOGFONTW lf;
1401 HFONT hFont, hOldFont;
1402 COLORREF clrsave;
1403 INT bkmode;
1404 WCHAR symbol;
1405 switch (popupMagic)
1406 {
1408 symbol = '2';
1409 break;
1411 symbol = '0';
1412 break;
1414 symbol = '1';
1415 break;
1417 symbol = 'r';
1418 break;
1419 default:
1420 ERR("Invalid popup magic bitmap %d\n", (int)popupMagic);
1421 return;
1422 }
1423 RtlZeroMemory(&lf, sizeof(LOGFONTW));
1424 RECTL_vInflateRect(r, -2, -2);
1425 lf.lfHeight = r->bottom - r->top;
1426 lf.lfWidth = 0;
1427 lf.lfWeight = FW_NORMAL;
1429 RtlCopyMemory(lf.lfFaceName, L"Marlett", sizeof(L"Marlett"));
1431 /* save font and text color */
1432 hOldFont = NtGdiSelectFont(dc, hFont);
1433 clrsave = GreGetTextColor(dc);
1434 bkmode = GreGetBkMode(dc);
1435 /* set color and drawing mode */
1437 if (inactive)
1438 {
1439 /* draw shadow */
1440 if (!hilite)
1441 {
1443 GreTextOutW(dc, r->left + 1, r->top + 1, &symbol, 1);
1444 }
1445 }
1447 /* draw selected symbol */
1448 GreTextOutW(dc, r->left, r->top, &symbol, 1);
1449 /* restore previous settings */
1450 IntGdiSetTextColor(dc, clrsave);
1451 NtGdiSelectFont(dc, hOldFont);
1452 IntGdiSetBkMode(dc, bkmode);
1454}
HFONT hFont
Definition: main.c:53
HDC dc
Definition: cylfrac.c:34
int FASTCALL GreGetBkMode(HDC)
Definition: dcutil.c:35
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG lfWidth
Definition: dimm.idl:60
BYTE lfCharSet
Definition: dimm.idl:67
HFONT FASTCALL GreCreateFontIndirectW(_In_ const LOGFONTW *lplf)
Definition: font.c:28
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
BOOL FASTCALL GreTextOutW(_In_ HDC hdc, _In_ INT nXStart, _In_ INT nYStart, _In_reads_(cchString) PCWCH lpString, _In_ INT cchString)
Definition: text.c:60
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define FW_NORMAL
Definition: wingdi.h:373

Referenced by MENU_DrawBitmapItem().

◆ MENU_DrawPopupMenu()

static void FASTCALL MENU_DrawPopupMenu ( PWND  wnd,
HDC  hdc,
PMENU  menu 
)
static

Definition at line 2599 of file menu.c.

2600{
2601 HBRUSH hPrevBrush = 0, brush = IntGetSysColorBrush(COLOR_MENU);
2602 RECT rect;
2603
2604 TRACE("DPM wnd=%p dc=%p menu=%p\n", wnd, hdc, menu);
2605
2606 IntGetClientRect( wnd, &rect );
2607
2608 if (menu && menu->hbrBack) brush = menu->hbrBack;
2609 if((hPrevBrush = NtGdiSelectBrush( hdc, brush ))
2611 {
2612 HPEN hPrevPen;
2613
2614 /* FIXME: Maybe we don't have to fill the background manually */
2615 FillRect(hdc, &rect, brush);
2616
2618 if ( hPrevPen )
2619 {
2620 TRACE("hmenu %p Style %08x\n", UserHMGetHandle(menu), (menu->fFlags & MNS_STYLE_MASK));
2621 /* draw menu items */
2622 if (menu && menu->cItems)
2623 {
2624 ITEM *item;
2625 UINT u;
2626
2627 item = menu->rgItems;
2628 for( u = menu->cItems; u > 0; u--, item++)
2629 {
2630 MENU_DrawMenuItem(wnd, menu, menu->spwndNotify, hdc, item,
2631 menu->cyMenu, FALSE, ODA_DRAWENTIRE);
2632 }
2633 /* draw scroll arrows */
2634 if (menu->dwArrowsOn)
2635 {
2637 }
2638 }
2639 }
2640 else
2641 {
2642 NtGdiSelectBrush( hdc, hPrevBrush );
2643 }
2644 }
2645}
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 * u
Definition: glfuncs.h:240
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
static void MENU_DrawScrollArrows(PMENU lppop, HDC hdc)
Definition: menu.c:2176
VOID FASTCALL IntGetClientRect(PWND WindowObject, RECTL *Rect)
Definition: winpos.c:92
#define NULL_PEN
Definition: wingdi.h:904

Referenced by PopupMenuWndProc().

◆ MENU_DrawScrollArrows()

static void MENU_DrawScrollArrows ( PMENU  lppop,
HDC  hdc 
)
static

Definition at line 2176 of file menu.c.

2177{
2178 UINT arrow_bitmap_height;
2179 RECT rect;
2180 UINT Flags = 0;
2181
2182 arrow_bitmap_height = gpsi->oembmi[OBI_DNARROW].cy;
2183
2184 rect.left = 0;
2185 rect.top = 0;
2186 rect.right = lppop->cxMenu;
2187 rect.bottom = arrow_bitmap_height;
2190
2191 rect.top = lppop->cyMenu - arrow_bitmap_height;
2192 rect.bottom = lppop->cyMenu;
2194 if (!(lppop->iTop < lppop->iMaxTop - (MENU_GetMaxPopupHeight(lppop) - 2 * arrow_bitmap_height)))
2197}
@ OBI_DNARROW
Definition: ntuser.h:969
#define DFCS_MENUARROWUP
Definition: undocuser.h:159
#define DFCS_MENUARROWDOWN
Definition: undocuser.h:160
static UINT MENU_GetMaxPopupHeight(PMENU lppop)
Definition: menu.c:1996

Referenced by MENU_DrawPopupMenu(), and MENU_EnsureMenuItemVisible().

◆ MENU_EndMenu()

void MENU_EndMenu ( PWND  pwnd)

Definition at line 2662 of file menu.c.

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

Referenced by IntDefWindowProc().

◆ MENU_EnsureMenuItemVisible()

void MENU_EnsureMenuItemVisible ( PMENU  lppop,
UINT  wIndex,
HDC  hdc 
)

Definition at line 3102 of file menu.c.

3103{
3105 if (lppop->dwArrowsOn)
3106 {
3107 ITEM *item = &lppop->rgItems[wIndex];
3108 UINT nMaxHeight = MENU_GetMaxPopupHeight(lppop);
3109 UINT nOldPos = lppop->iTop;
3110 RECT rc;
3111 UINT arrow_bitmap_height;
3112 PWND pWnd = ValidateHwndNoErr(lppop->hWnd);
3113
3114 IntGetClientRect(pWnd, &rc);
3115
3116 arrow_bitmap_height = gpsi->oembmi[OBI_DNARROW].cy;
3117
3118 rc.top += arrow_bitmap_height;
3119 rc.bottom -= arrow_bitmap_height;
3120
3121 nMaxHeight -= UserGetSystemMetrics(SM_CYBORDER) + 2 * arrow_bitmap_height;
3122 UserRefObjectCo(pWnd, &Ref);
3123 if (item->cyItem > lppop->iTop + nMaxHeight)
3124 {
3125 lppop->iTop = item->cyItem - nMaxHeight;
3126 IntScrollWindow(pWnd, 0, nOldPos - lppop->iTop, &rc, &rc);
3127 MENU_DrawScrollArrows(lppop, hdc);
3128 //ERR("Scroll Down iTop %d iMaxTop %d nMaxHeight %d\n",lppop->iTop,lppop->iMaxTop,nMaxHeight);
3129 }
3130 else if (item->yItem < lppop->iTop)
3131 {
3132 lppop->iTop = item->yItem;
3133 IntScrollWindow(pWnd, 0, nOldPos - lppop->iTop, &rc, &rc);
3134 MENU_DrawScrollArrows(lppop, hdc);
3135 //ERR("Scroll Up iTop %d iMaxTop %d nMaxHeight %d\n",lppop->iTop,lppop->iMaxTop,nMaxHeight);
3136 }
3137 UserDerefObjectCo(pWnd);
3138 }
3139}
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:43
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
BOOL FASTCALL IntScrollWindow(PWND, int, int, CONST RECT *, CONST RECT *)
Definition: scrollex.c:458
Definition: object.h:4

Referenced by MENU_SelectItem().

◆ MENU_ExecFocusedItem()

static INT FASTCALL MENU_ExecFocusedItem ( MTRACKER pmt,
PMENU  Menu,
UINT  Flags 
)
static

Definition at line 3478 of file menu.c.

3479{
3480 PITEM Item;
3481
3482 TRACE("%p menu=%p\n", pmt, Menu);
3483
3484 if (!Menu || !Menu->cItems || Menu->iItem == NO_SELECTED_ITEM)
3485 {
3486 return -1;
3487 }
3488
3489 Item = &Menu->rgItems[Menu->iItem];
3490
3491 TRACE("%p %08x %p\n", Menu, Item->wID, Item->spSubMenu);
3492
3493 if (!(Item->spSubMenu))
3494 {
3495 if (!(Item->fState & (MF_GRAYED | MF_DISABLED)) && !(Item->fType & MF_SEPARATOR))
3496 {
3497 /* If TPM_RETURNCMD is set you return the id, but
3498 do not send a message to the owner */
3499 if (!(Flags & TPM_RETURNCMD))
3500 {
3501 if (Menu->fFlags & MNF_SYSMENU)
3502 {
3504 MAKELPARAM((SHORT) pmt->Pt.x, (SHORT) pmt->Pt.y));
3505 }
3506 else
3507 {
3508 DWORD dwStyle = ((Menu->fFlags & MNS_STYLE_MASK) | ( pmt->TopMenu ? (pmt->TopMenu->fFlags & MNS_STYLE_MASK) : 0) );
3509
3510 if (dwStyle & MNS_NOTIFYBYPOS)
3511 UserPostMessage(UserHMGetHandle(pmt->OwnerWnd), WM_MENUCOMMAND, Menu->iItem, (LPARAM)UserHMGetHandle(Menu));
3512 else
3514 }
3515 }
3516 return Item->wID;
3517 }
3518 }
3519 else
3520 {
3521 pmt->CurrentMenu = MENU_ShowSubPopup(pmt->OwnerWnd, Menu, TRUE, Flags);
3522 return -2;
3523 }
3524
3525 return -1;
3526}
short SHORT
Definition: pedump.c:59
#define MNS_NOTIFYBYPOS
Definition: winuser.h:770
#define WM_SYSCOMMAND
Definition: winuser.h:1760
#define WM_COMMAND
Definition: winuser.h:1759

Referenced by MENU_ButtonUp(), and MENU_TrackMenu().

◆ MENU_ExitTracking()

static BOOL FASTCALL MENU_ExitTracking ( PWND  pWnd,
BOOL  bPopup,
UINT  wFlags 
)
static

Definition at line 4464 of file menu.c.

4465{
4466 TRACE("Exit Track hwnd=%p bPopup %d\n", UserHMGetHandle(pWnd), bPopup);
4467
4468 IntNotifyWinEvent( EVENT_SYSTEM_MENUEND, pWnd, OBJID_WINDOW, CHILDID_SELF, 0);
4469
4470 if (!(wFlags & TPM_NONOTIFY))
4472
4474
4475 top_popup = 0;
4477
4478 return TRUE;
4479}
BOOL FASTCALL co_UserShowCaret(PWND Window OPTIONAL)
Definition: caret.c:262
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:178
#define OBJID_WINDOW
Definition: winable.h:15
#define CHILDID_SELF
Definition: winable.h:14
#define WM_EXITMENULOOP
Definition: winuser.h:1824

Referenced by IntTrackPopupMenuEx(), MENU_TrackKbdMenuBar(), and MENU_TrackMouseMenuBar().

◆ 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}

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_FindItemByCoords()

static ITEM * MENU_FindItemByCoords ( MENU menu,
POINT  pt,
UINT pos 
)
static

Definition at line 1480 of file menu.c.

1481{
1482 ITEM *item;
1483 UINT i;
1484 INT cx, cy;
1485 RECT rect;
1486 PWND pWnd = ValidateHwndNoErr(menu->hWnd);
1487
1488 if (!IntGetWindowRect(pWnd, &rect)) return NULL;
1489
1493
1494 if (pWnd->ExStyle & WS_EX_LAYOUTRTL)
1495 pt.x = rect.right - 1 - pt.x;
1496 else
1497 pt.x -= rect.left;
1498 pt.y -= rect.top;
1499 item = menu->rgItems;
1500 for (i = 0; i < menu->cItems; i++, item++)
1501 {
1502 //rect = item->rect;
1503 rect.left = item->xItem;
1504 rect.top = item->yItem;
1505 rect.right = item->cxItem; // Do this for now......
1506 rect.bottom = item->cyItem;
1507
1509 if (RECTL_bPointInRect(&rect, pt.x, pt.y))
1510 {
1511 if (pos) *pos = i;
1512 return item;
1513 }
1514 }
1515 return NULL;
1516}
#define pt(x, y)
Definition: drawing.c:79
BOOL FASTCALL IntGetWindowRect(PWND Wnd, RECTL *Rect)
Definition: winpos.c:121
FORCEINLINE BOOL RECTL_bPointInRect(_In_ const RECTL *prcl, _In_ INT x, _In_ INT y)
Definition: rect.h:52
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390

Referenced by IntMenuItemFromPoint(), MENU_ButtonDown(), MENU_ButtonUp(), and MENU_MouseMove().

◆ MENU_FindItemByKey()

static UINT FASTCALL MENU_FindItemByKey ( PWND  WndOwner,
PMENU  menu,
WCHAR  Key,
BOOL  ForceMenuChar 
)
static

Definition at line 1535 of file menu.c.

1537{
1538 LRESULT MenuChar;
1539 WORD Flags = 0;
1540
1541 TRACE("\tlooking for '%c' (0x%02x) in [%p]\n", (char)Key, Key, menu );
1542
1543 if (!menu || !VerifyMenu(menu))
1544 menu = co_IntGetSubMenu( UserGetMenuObject(WndOwner->SystemMenu), 0 );
1545 if (menu)
1546 {
1547 ITEM *item = menu->rgItems;
1548
1549 if ( !ForceMenuChar )
1550 {
1551 UINT i;
1553
1554 for (i = 0; i < menu->cItems; i++, item++)
1555 {
1556 LPWSTR text = item->Xlpstr;
1557 if( text)
1558 {
1559 const WCHAR *p = text - 2;
1560 do
1561 {
1562 const WCHAR *q = p + 2;
1563 p = wcschr (q, '&');
1564 if (!p && cjk) p = wcschr (q, '\036'); /* Japanese Win16 */
1565 }
1566 while (p != NULL && p [1] == '&');
1567 if (p && (towupper(p[1]) == towupper(Key))) return i;
1568 }
1569 }
1570 }
1571
1572 Flags |= menu->fFlags & MNF_POPUP ? MF_POPUP : 0;
1573 Flags |= menu->fFlags & MNF_SYSMENU ? MF_SYSMENU : 0;
1574
1575 MenuChar = co_IntSendMessage( UserHMGetHandle(WndOwner), WM_MENUCHAR,
1577 if (HIWORD(MenuChar) == MNC_EXECUTE) return LOWORD(MenuChar);
1578 if (HIWORD(MenuChar) == MNC_CLOSE) return (UINT)(-2);
1579 }
1580 return (UINT)(-1);
1581}
unsigned short WORD
Definition: ntddk_ex.h:93
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
LPCSTR text
Definition: menu.c:77
HMENU SystemMenu
Definition: ntuser.h:728
#define towupper(c)
Definition: wctype.h:99
PMENU FASTCALL VerifyMenu(PMENU pMenu)
Definition: menu.c:201
LONG_PTR LRESULT
Definition: windef.h:209
#define MAKEWPARAM(l, h)
Definition: winuser.h:4085
#define MNC_EXECUTE
Definition: winuser.h:2587
#define WM_MENUCHAR
Definition: winuser.h:1767
#define MNC_CLOSE
Definition: winuser.h:2586
#define SM_DBCSENABLED
Definition: winuser.h:1016
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by MENU_TrackKbdMenuBar(), and MENU_TrackMenu().

◆ MENU_FindSubMenu()

static UINT FASTCALL MENU_FindSubMenu ( PMENU menu,
PMENU  SubTarget 
)
static

Definition at line 564 of file menu.c.

565{
566 UINT i;
567 PITEM item;
568
569 item = ((PMENU)*menu)->rgItems;
570 for (i = 0; i < ((PMENU)*menu)->cItems; i++, item++)
571 {
572 if (!item->spSubMenu)
573 continue;
574 else
575 {
576 if (item->spSubMenu == SubTarget)
577 {
578 return i;
579 }
580 else
581 {
582 PMENU pSubMenu = item->spSubMenu;
583 UINT pos = MENU_FindSubMenu( &pSubMenu, SubTarget );
584 if (pos != NO_SELECTED_ITEM)
585 {
586 *menu = pSubMenu;
587 return pos;
588 }
589 }
590 }
591 }
592 return NO_SELECTED_ITEM;
593}

Referenced by IntFindSubMenu(), MENU_FindSubMenu(), and MENU_SelectItem().

◆ MENU_GetBitmapItemSize()

static void FASTCALL MENU_GetBitmapItemSize ( PITEM  lpitem,
SIZE size,
PWND  WndOwner 
)
static

Definition at line 1588 of file menu.c.

1589{
1590 BITMAP bm;
1591 HBITMAP bmp = lpitem->hbmp;
1592
1593 size->cx = size->cy = 0;
1594
1595 /* check if there is a magic menu item associated with this item */
1596 if (IS_MAGIC_BITMAP(bmp))
1597 {
1598 switch((INT_PTR) bmp)
1599 {
1601 {
1602 MEASUREITEMSTRUCT measItem;
1603 measItem.CtlType = ODT_MENU;
1604 measItem.CtlID = 0;
1605 measItem.itemID = lpitem->wID;
1606 measItem.itemWidth = lpitem->cxItem - lpitem->xItem; //lpitem->Rect.right - lpitem->Rect.left;
1607 measItem.itemHeight = lpitem->cyItem - lpitem->yItem; //lpitem->Rect.bottom - lpitem->Rect.top;
1608 measItem.itemData = lpitem->dwItemData;
1609 co_IntSendMessage( UserHMGetHandle(WndOwner), WM_MEASUREITEM, 0, (LPARAM)&measItem);
1610 size->cx = measItem.itemWidth;
1611 size->cy = measItem.itemHeight;
1612 TRACE("HBMMENU_CALLBACK Height %d Width %d\n",measItem.itemHeight,measItem.itemWidth);
1613 return;
1614 }
1615 break;
1616
1617 case (INT_PTR) HBMMENU_SYSTEM:
1618 if (lpitem->dwItemData)
1619 {
1620 bmp = (HBITMAP) lpitem->dwItemData;
1621 break;
1622 }
1623 /* fall through */
1633 /* FIXME: Why we need to subtract these magic values? */
1634 /* to make them smaller than the menu bar? */
1637 return;
1638 }
1639 }
1640
1641 if (GreGetObject(bmp, sizeof(BITMAP), &bm))
1642 {
1643 size->cx = bm.bmWidth;
1644 size->cy = bm.bmHeight;
1645 }
1646}
#define SM_CYSIZE
Definition: winuser.h:1003

Referenced by MENU_CalcItemSize().

◆ MENU_GetMaxPopupHeight()

static UINT MENU_GetMaxPopupHeight ( PMENU  lppop)
static

Definition at line 1996 of file menu.c.

1997{
1998 if (lppop->cyMax)
1999 {
2000 //ERR("MGMaxPH cyMax %d\n",lppop->cyMax);
2001 return lppop->cyMax;
2002 }
2003 //ERR("MGMaxPH SyMax %d\n",UserGetSystemMetrics(SM_CYSCREEN) - UserGetSystemMetrics(SM_CYBORDER));
2005}
#define SM_CYSCREEN
Definition: winuser.h:971

Referenced by MENU_DrawScrollArrows(), MENU_EnsureMenuItemVisible(), and MENU_PopupMenuCalcSize().

◆ MENU_GetStartOfNextColumn()

static UINT MENU_GetStartOfNextColumn ( PMENU  menu)
static

Definition at line 437 of file menu.c.

439{
440 PITEM pItem;
441 UINT i;
442
443 if(!menu)
444 return NO_SELECTED_ITEM;
445
446 i = menu->iItem + 1;
447 if( i == NO_SELECTED_ITEM )
448 return i;
449
450 pItem = menu->rgItems;
451 if (!pItem) return NO_SELECTED_ITEM;
452
453 for( ; i < menu->cItems; ++i ) {
454 if (pItem[i].fType & (MF_MENUBREAK | MF_MENUBARBREAK))
455 return i;
456 }
457
458 return NO_SELECTED_ITEM;
459}
#define MF_MENUBREAK
Definition: winuser.h:134

Referenced by MENU_KeyRight().

◆ MENU_GetStartOfPrevColumn()

static UINT MENU_GetStartOfPrevColumn ( PMENU  menu)
static

Definition at line 467 of file menu.c.

469{
470 UINT i;
471 PITEM pItem;
472
473 if( !menu )
474 return NO_SELECTED_ITEM;
475
476 if( menu->iItem == 0 || menu->iItem == NO_SELECTED_ITEM )
477 return NO_SELECTED_ITEM;
478
479 pItem = menu->rgItems;
480 if (!pItem) return NO_SELECTED_ITEM;
481
482 /* Find the start of the column */
483
484 for(i = menu->iItem; i != 0 &&
485 !(pItem[i].fType & (MF_MENUBREAK | MF_MENUBARBREAK));
486 --i); /* empty */
487
488 if(i == 0)
489 return NO_SELECTED_ITEM;
490
491 for(--i; i != 0; --i) {
492 if (pItem[i].fType & (MF_MENUBREAK | MF_MENUBARBREAK))
493 break;
494 }
495
496 TRACE("ret %d.\n", i );
497
498 return i;
499}

Referenced by MENU_KeyLeft().

◆ MENU_GetSubPopup()

static PMENU MENU_GetSubPopup ( PMENU  menu)
static

Definition at line 3716 of file menu.c.

3717{
3718 ITEM *item;
3719
3720 if ((!menu) || (menu->iItem == NO_SELECTED_ITEM)) return 0;
3721
3722 item = &menu->rgItems[menu->iItem];
3723 if (item && (item->spSubMenu) && (item->fState & MF_MOUSESELECT))
3724 {
3725 return item->spSubMenu;
3726 }
3727 return 0;
3728}

Referenced by MENU_KeyEscape(), and MENU_KeyLeft().

◆ MENU_GetSystemMenu()

PMENU FASTCALL MENU_GetSystemMenu ( PWND  Window,
PMENU  Popup 
)

Definition at line 5304 of file menu.c.

5305{
5306 PMENU Menu, NewMenu = NULL, SysMenu = NULL;
5307 HMENU hSysMenu, hNewMenu = NULL;
5308 ROSMENUITEMINFO ItemInfoSet = {0};
5309 ROSMENUITEMINFO ItemInfo = {0};
5310 UNICODE_STRING MenuName;
5311
5312 hSysMenu = UserCreateMenu(Window->head.rpdesk, FALSE);
5313 if (NULL == hSysMenu)
5314 {
5315 return NULL;
5316 }
5317 SysMenu = UserGetMenuObject(hSysMenu);
5318 if (NULL == SysMenu)
5319 {
5320 UserDestroyMenu(hSysMenu);
5321 return NULL;
5322 }
5323
5324 SysMenu->fFlags |= MNF_SYSMENU;
5325 SysMenu->hWnd = UserHMGetHandle(Window);
5326
5327 if (!Popup)
5328 {
5329 //hNewMenu = co_IntLoadSysMenuTemplate();
5330 if ( Window->ExStyle & WS_EX_MDICHILD )
5331 {
5332 RtlInitUnicodeString( &MenuName, L"SYSMENUMDI");
5333 hNewMenu = co_IntCallLoadMenu( hModClient, &MenuName);
5334 }
5335 else
5336 {
5337 RtlInitUnicodeString( &MenuName, L"SYSMENU");
5338 hNewMenu = co_IntCallLoadMenu( hModClient, &MenuName);
5339 //ERR("%wZ\n",&MenuName);
5340 }
5341 if (!hNewMenu)
5342 {
5343 ERR("No Menu!!\n");
5344 IntDestroyMenuObject(SysMenu, FALSE);
5345 return NULL;
5346 }
5347 Menu = UserGetMenuObject(hNewMenu);
5348 if (!Menu)
5349 {
5350 IntDestroyMenuObject(SysMenu, FALSE);
5351 return NULL;
5352 }
5353
5354 // Do the rest in here.
5355
5357
5358 ItemInfoSet.cbSize = sizeof( MENUITEMINFOW);
5359 ItemInfoSet.fMask = MIIM_BITMAP;
5360 ItemInfoSet.hbmpItem = HBMMENU_POPUP_CLOSE;
5361 IntMenuItemInfo(Menu, SC_CLOSE, FALSE, &ItemInfoSet, TRUE, NULL);
5362 ItemInfoSet.hbmpItem = HBMMENU_POPUP_RESTORE;
5363 IntMenuItemInfo(Menu, SC_RESTORE, FALSE, &ItemInfoSet, TRUE, NULL);
5364 ItemInfoSet.hbmpItem = HBMMENU_POPUP_MAXIMIZE;
5365 IntMenuItemInfo(Menu, SC_MAXIMIZE, FALSE, &ItemInfoSet, TRUE, NULL);
5366 ItemInfoSet.hbmpItem = HBMMENU_POPUP_MINIMIZE;
5367 IntMenuItemInfo(Menu, SC_MINIMIZE, FALSE, &ItemInfoSet, TRUE, NULL);
5368
5369 NewMenu = IntCloneMenu(Menu);
5370 if (NewMenu == NULL)
5371 {
5373 IntDestroyMenuObject(SysMenu, FALSE);
5374 return NULL;
5375 }
5376
5377 IntReleaseMenuObject(NewMenu);
5379
5381 }
5382 else
5383 {
5384 NewMenu = Popup;
5385 }
5386 if (NewMenu)
5387 {
5388 NewMenu->fFlags |= MNF_SYSMENU | MNF_POPUP;
5389
5390 if (Window->pcls->style & CS_NOCLOSE)
5392
5393 ItemInfo.cbSize = sizeof(MENUITEMINFOW);
5395 ItemInfo.fType = MF_POPUP;
5396 ItemInfo.fState = MFS_ENABLED;
5397 ItemInfo.dwTypeData = NULL;
5398 ItemInfo.cch = 0;
5399 ItemInfo.hSubMenu = UserHMGetHandle(NewMenu);
5400 IntInsertMenuItem(SysMenu, (UINT) -1, TRUE, &ItemInfo, NULL);
5401
5402 return SysMenu;
5403 }
5404 ERR("failed to load system menu!\n");
5405 return NULL;
5406}
@ Popup
Definition: console.h:35
HINSTANCE hModClient
Definition: ntuser.c:25
HMENU APIENTRY co_IntCallLoadMenu(HINSTANCE hModule, PUNICODE_STRING pMenuName)
Definition: callback.c:903
BOOL FASTCALL UserDestroyMenu(HMENU hMenu)
Definition: menu.c:5820
PMENU FASTCALL IntCloneMenu(PMENU Source)
Definition: menu.c:822
BOOL FASTCALL IntInsertMenuItem(_In_ PMENU MenuObject, UINT uItem, BOOL fByPosition, PROSMENUITEMINFO ItemInfo, PUNICODE_STRING lpstr)
Definition: menu.c:691
HMENU FASTCALL UserCreateMenu(PDESKTOP Desktop, BOOL PopupMenu)
Definition: menu.c:5058
BOOL FASTCALL IntMenuItemInfo(PMENU Menu, UINT Item, BOOL ByPosition, PROSMENUITEMINFO ItemInfo, BOOL SetOrGet, PUNICODE_STRING lpstr)
Definition: menu.c:5102
#define MFS_ENABLED
Definition: winuser.h:761
struct tagMENUITEMINFOW MENUITEMINFOW

Referenced by IntGetSystemMenu(), and IntSetSystemMenu().

◆ MENU_HideSubPopups()

static void FASTCALL MENU_HideSubPopups ( PWND  pWndOwner,
PMENU  Menu,
BOOL  SendMenuSelect,
UINT  wFlags 
)
static

Definition at line 3267 of file menu.c.

3269{
3270 TRACE("owner=%x menu=%x 0x%04x\n", pWndOwner, Menu, SendMenuSelect);
3271
3272 if ( Menu && top_popup )
3273 {
3274 PITEM Item;
3275
3276 if (Menu->iItem != NO_SELECTED_ITEM)
3277 {
3278 Item = &Menu->rgItems[Menu->iItem];
3279 if (!(Item->spSubMenu) ||
3280 !(Item->fState & MF_MOUSESELECT)) return;
3281 Item->fState &= ~MF_MOUSESELECT;
3282 }
3283 else
3284 return;
3285
3286 if (Item->spSubMenu)
3287 {
3288 PWND pWnd;
3289 if (!VerifyMenu(Item->spSubMenu)) return;
3290 MENU_HideSubPopups(pWndOwner, Item->spSubMenu, FALSE, wFlags);
3291 MENU_SelectItem(pWndOwner, Item->spSubMenu, NO_SELECTED_ITEM, SendMenuSelect, NULL);
3292 TRACE("M_HSP top p hm %p pWndOwner IDMenu %p\n",top_popup_hmenu,pWndOwner->IDMenu);
3293 pWnd = ValidateHwndNoErr(Item->spSubMenu->hWnd);
3294 if (pWnd != NULL)
3295 {
3297 }
3298
3299 /* Native returns handle to destroyed window */
3300 if (!(wFlags & TPM_NONOTIFY))
3301 {
3302 co_IntSendMessage( UserHMGetHandle(pWndOwner), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(Item->spSubMenu),
3303 MAKELPARAM(0, IS_SYSTEM_MENU(Item->spSubMenu) ? MF_SYSMENU : 0));
3304 }
3306 // Call WM_UNINITMENUPOPUP FIRST before destroy!!
3307 // Fixes todo_wine User32 test menu.c line 2239 GetMenuBarInfo callback....
3308 //
3309 Item->spSubMenu->hWnd = NULL;
3311 }
3312 }
3313}

Referenced by IntHiliteMenuItem(), MENU_DoNextMenu(), MENU_HideSubPopups(), MENU_KeyEscape(), MENU_KeyLeft(), MENU_KeyRight(), MENU_SwitchTracking(), and MENU_TrackMenu().

◆ MENU_InitPopup()

static BOOL MENU_InitPopup ( PWND  pWndOwner,
PMENU  menu,
UINT  flags 
)
static

Definition at line 2781 of file menu.c.

2782{
2783 PWND pWndCreated;
2784 PPOPUPMENU pPopupMenu;
2785 CREATESTRUCTW Cs;
2786 LARGE_STRING WindowName;
2787 UNICODE_STRING ClassName;
2789
2790 TRACE("owner=%p hmenu=%p\n", pWndOwner, menu);
2791
2792 menu->spwndNotify = pWndOwner;
2793
2794 if (flags & TPM_LAYOUTRTL || pWndOwner->ExStyle & WS_EX_LAYOUTRTL)
2795 ex_style |= WS_EX_LAYOUTRTL;
2796
2797 ClassName.Buffer = WC_MENU;
2798 ClassName.Length = 0;
2799
2800 RtlZeroMemory(&WindowName, sizeof(WindowName));
2801 RtlZeroMemory(&Cs, sizeof(Cs));
2803 Cs.dwExStyle = ex_style;
2804 Cs.hInstance = hModClient; // hModuleWin; // Server side winproc!
2805 Cs.lpszName = (LPCWSTR) &WindowName;
2806 Cs.lpszClass = (LPCWSTR) &ClassName;
2808 Cs.hwndParent = UserHMGetHandle(pWndOwner);
2809
2810 /* NOTE: In Windows, top menu popup is not owned. */
2811 pWndCreated = co_UserCreateWindowEx( &Cs, &ClassName, &WindowName, NULL, WINVER );
2812
2813 if( !pWndCreated ) return FALSE;
2814
2815 //
2816 // Setup pop up menu structure.
2817 //
2818 menu->hWnd = UserHMGetHandle(pWndCreated);
2819
2820 pPopupMenu = ((PMENUWND)pWndCreated)->ppopupmenu;
2821
2822 pPopupMenu->spwndActivePopup = pWndCreated; // top_popup = MenuInfo.Wnd or menu->hWnd
2823 pPopupMenu->spwndNotify = pWndOwner; // Same as MenuInfo.spwndNotify(which could be wrong) or menu->hwndOwner
2824 //pPopupMenu->spmenu = menu; Should be set up already from WM_CREATE!
2825
2826 pPopupMenu->fIsTrackPopup = !!(flags & TPM_POPUPMENU);
2827 pPopupMenu->fIsSysMenu = !!(flags & TPM_SYSTEM_MENU);
2828 pPopupMenu->fNoNotify = !!(flags & TPM_NONOTIFY);
2829 pPopupMenu->fRightButton = !!(flags & TPM_RIGHTBUTTON);
2830 pPopupMenu->fSynchronous = !!(flags & TPM_RETURNCMD);
2831
2832 if (pPopupMenu->fRightButton)
2833 pPopupMenu->fFirstClick = !!(UserGetKeyState(VK_RBUTTON) & 0x8000);
2834 else
2835 pPopupMenu->fFirstClick = !!(UserGetKeyState(VK_LBUTTON) & 0x8000);
2836
2837 if (gpsi->aiSysMet[SM_MENUDROPALIGNMENT] ||
2838 menu->fFlags & MNF_RTOL)
2839 {
2840 pPopupMenu->fDroppedLeft = TRUE;
2841 }
2842 return TRUE;
2843}
struct _MENUWND * PMENUWND
DWORD FASTCALL UserGetKeyState(DWORD dwKey)
Definition: msgqueue.c:221
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_BORDER
Definition: pedump.c:625
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
LPCWSTR lpszClass
Definition: winuser.h:3041
LPCWSTR lpszName
Definition: winuser.h:3040
LPVOID lpCreateParams
Definition: winuser.h:3031
HINSTANCE hInstance
Definition: winuser.h:3032
ULONG fRightButton
Definition: ntuser.h:449
ULONG fFirstClick
Definition: ntuser.h:452
struct _WND * spwndNotify
Definition: ntuser.h:469
ULONG fNoNotify
Definition: ntuser.h:454
ULONG fIsSysMenu
Definition: ntuser.h:445
ULONG fSynchronous
Definition: ntuser.h:451
struct _WND * spwndActivePopup
Definition: ntuser.h:475
ULONG fDroppedLeft
Definition: ntuser.h:447
ULONG fIsTrackPopup
Definition: ntuser.h:446
#define WINVER
Definition: targetver.h:11
#define TPM_SYSTEM_MENU
Definition: undocuser.h:74
#define WC_MENU
Definition: undocuser.h:11
PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW *Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, PVOID acbiBuffer, DWORD dwVer)
Definition: window.c:2180
#define SM_MENUDROPALIGNMENT
Definition: winuser.h:1014
#define VK_RBUTTON
Definition: winuser.h:2210
#define WS_EX_PALETTEWINDOW
Definition: winuser.h:399
#define VK_LBUTTON
Definition: winuser.h:2209
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by IntTrackPopupMenuEx(), and MENU_ShowSubPopup().

◆ MENU_InitSysMenuPopup()

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

Definition at line 1362 of file menu.c.

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

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

◆ MENU_InitTracking()

static BOOL FASTCALL MENU_InitTracking ( PWND  pWnd,
PMENU  Menu,
BOOL  bPopup,
UINT  wFlags 
)
static

Definition at line 4404 of file menu.c.

4405{
4406 HWND capture_win;
4408
4409 TRACE("hwnd=%p hmenu=%p\n", UserHMGetHandle(pWnd), UserHMGetHandle(Menu));
4410
4412
4413 /* This makes the menus of applications built with Delphi work.
4414 * It also enables menus to be displayed in more than one window,
4415 * but there are some bugs left that need to be fixed in this case.
4416 */
4417 if (!bPopup)
4418 {
4419 Menu->hWnd = UserHMGetHandle(pWnd);
4420 }
4421
4422 if (!top_popup) {
4423 top_popup = Menu->hWnd;
4425 }
4426
4428 fInEndMenu = FALSE;
4429
4430 /* Send WM_ENTERMENULOOP and WM_INITMENU message only if TPM_NONOTIFY flag is not specified */
4431 if (!(wFlags & TPM_NONOTIFY))
4432 {
4434 }
4435
4436 //
4437 // Capture is set before calling WM_INITMENU and after WM_ENTERMENULOOP, see msg_menu.
4438 //
4439 capture_win = (wFlags & TPM_POPUPMENU) ? Menu->hWnd : UserHMGetHandle(pWnd);
4440 MsqSetStateWindow(pti, MSQ_STATE_MENUOWNER, capture_win); // 1
4441 co_UserSetCapture(capture_win); // 2
4442 pti->MessageQueue->QF_flags |= QF_CAPTURELOCKED; // Set the Q bits so noone can change this!
4443
4445
4446 if (!(wFlags & TPM_NONOTIFY))
4447 {
4449 /* If an app changed/recreated menu bar entries in WM_INITMENU
4450 * menu sizes will be recalculated once the menu created/shown.
4451 */
4452 }
4453
4454 IntNotifyWinEvent( EVENT_SYSTEM_MENUSTART,
4455 pWnd,
4457 CHILDID_SELF, 0);
4458 return TRUE;
4459}
BOOL FASTCALL co_UserHideCaret(PWND Window OPTIONAL)
Definition: caret.c:226
#define OBJID_MENU
Definition: winable.h:18
#define OBJID_SYSMENU
Definition: winable.h:16
#define WM_INITMENU
Definition: winuser.h:1764
#define WM_ENTERMENULOOP
Definition: winuser.h:1823
#define WM_SETCURSOR
Definition: winuser.h:1655

Referenced by IntTrackPopupMenuEx(), MENU_TrackKbdMenuBar(), and MENU_TrackMouseMenuBar().

◆ MENU_InsertItem()

ITEM * MENU_InsertItem ( PMENU  menu,
UINT  pos,
UINT  flags,
PMENU submenu,
UINT npos 
)

Definition at line 639 of file menu.c.

640{
641 ITEM *newItems;
642
643 /* Find where to insert new item */
644
645 if (flags & MF_BYPOSITION) {
646 if (pos > menu->cItems)
647 pos = menu->cItems;
648 } else {
649 if (!MENU_FindItem( &menu, &pos, flags ))
650 {
651 if (submenu) *submenu = menu;
652 if (npos) *npos = pos;
653 pos = menu->cItems;
654 }
655 }
656
657 /* Make sure that MDI system buttons stay on the right side.
658 * Note: XP treats only bitmap handles 1 - 6 as "magic" ones
659 * regardless of their id.
660 */
661 while ( pos > 0 &&
662 (INT_PTR)menu->rgItems[pos - 1].hbmp >= (INT_PTR)HBMMENU_SYSTEM &&
664 pos--;
665
666 TRACE("inserting at %u flags %x\n", pos, flags);
667
668 /* Create new items array */
669
670 newItems = DesktopHeapAlloc(menu->head.rpdesk, sizeof(ITEM) * (menu->cItems+1) );
671 if (!newItems)
672 {
673 WARN("allocation failed\n" );
674 return NULL;
675 }
676 if (menu->cItems > 0)
677 {
678 /* Copy the old array into the new one */
679 if (pos > 0) RtlCopyMemory( newItems, menu->rgItems, pos * sizeof(ITEM) );
680 if (pos < menu->cItems) RtlCopyMemory( &newItems[pos+1], &menu->rgItems[pos], (menu->cItems-pos)*sizeof(ITEM) );
681 DesktopHeapFree(menu->head.rpdesk, menu->rgItems );
682 }
683 menu->rgItems = newItems;
684 menu->cItems++;
685 RtlZeroMemory( &newItems[pos], sizeof(*newItems) );
686 menu->cyMenu = 0; /* force size recalculate */
687 return &newItems[pos];
688}
static const size_t npos
Definition: _string_npos.h:26

Referenced by IntInsertMenuItem().

◆ MENU_IsMenuActive()

PWND MENU_IsMenuActive ( VOID  )

Definition at line 2650 of file menu.c.

2651{
2653}

Referenced by IntDefWindowProc().

◆ MENU_KeyEscape()

static BOOL FASTCALL MENU_KeyEscape ( MTRACKER pmt,
UINT  Flags 
)
static

Definition at line 3913 of file menu.c.

3914{
3915 BOOL EndMenu = TRUE;
3916
3917 if (pmt->CurrentMenu != pmt->TopMenu)
3918 {
3919 if (pmt->CurrentMenu && (pmt->CurrentMenu->fFlags & MNF_POPUP))
3920 {
3921 PMENU MenuPrev, MenuTmp;
3922
3923 MenuPrev = MenuTmp = pmt->TopMenu;
3924
3925 /* close topmost popup */
3926 while (MenuTmp != pmt->CurrentMenu)
3927 {
3928 MenuPrev = MenuTmp;
3929 MenuTmp = MENU_GetSubPopup(MenuPrev);
3930 }
3931
3932 MENU_HideSubPopups(pmt->OwnerWnd, MenuPrev, TRUE, Flags);
3933 pmt->CurrentMenu = MenuPrev;
3934 EndMenu = FALSE;
3935 }
3936 }
3937
3938 return EndMenu;
3939}
static PMENU MENU_GetSubPopup(PMENU menu)
Definition: menu.c:3716
BOOL WINAPI EndMenu(void)

Referenced by MENU_TrackMenu().

◆ MENU_KeyLeft()

static void FASTCALL MENU_KeyLeft ( MTRACKER pmt,
UINT  Flags,
UINT  msg 
)
static

Definition at line 3946 of file menu.c.

3947{
3948 PMENU MenuTmp, MenuPrev;
3949 UINT PrevCol;
3950
3951 MenuPrev = MenuTmp = pmt->TopMenu;
3952
3953 /* Try to move 1 column left (if possible) */
3954 if ( (PrevCol = MENU_GetStartOfPrevColumn(pmt->CurrentMenu)) != NO_SELECTED_ITEM)
3955 {
3956 MENU_SelectItem(pmt->OwnerWnd, pmt->CurrentMenu, PrevCol, TRUE, 0);
3957 return;
3958 }
3959
3960 /* close topmost popup */
3961 while (MenuTmp != pmt->CurrentMenu)
3962 {
3963 MenuPrev = MenuTmp;
3964 MenuTmp = MENU_GetSubPopup(MenuPrev);
3965 }
3966
3967 MENU_HideSubPopups(pmt->OwnerWnd, MenuPrev, TRUE, Flags);
3968 pmt->CurrentMenu = MenuPrev;
3969
3970 if ((MenuPrev == pmt->TopMenu) && !(pmt->TopMenu->fFlags & MNF_POPUP))
3971 {
3972 /* move menu bar selection if no more popups are left */
3973
3974 if (!MENU_DoNextMenu(pmt, VK_LEFT, Flags))
3976
3977 if (MenuPrev != MenuTmp || pmt->TrackFlags & TF_SUSPENDPOPUP)
3978 {
3979 /* A sublevel menu was displayed - display the next one
3980 * unless there is another displacement coming up */
3981
3982 if (!MENU_SuspendPopup(pmt, msg))
3984 TRUE, Flags);
3985 }
3986 }
3987}
#define msg(x)
Definition: auth_time.c:54
UINT TrackFlags
Definition: menu.c:80
static LRESULT FASTCALL MENU_DoNextMenu(MTRACKER *pmt, UINT Vk, UINT wFlags)
Definition: menu.c:3735
static UINT MENU_GetStartOfPrevColumn(PMENU menu)
Definition: menu.c:467
static BOOL FASTCALL MENU_SuspendPopup(MTRACKER *pmt, UINT uMsg)
Definition: menu.c:3877
static void FASTCALL MENU_MoveSelection(PWND pwndOwner, PMENU menu, INT offset)
Definition: menu.c:3231
#define TF_SUSPENDPOPUP
Definition: menu.c:36
#define ITEM_PREV
Definition: menu.c:92

Referenced by MENU_TrackMenu().

◆ MENU_KeyRight()

static void FASTCALL MENU_KeyRight ( MTRACKER pmt,
UINT  Flags,
UINT  msg 
)
static

Definition at line 3994 of file menu.c.

3995{
3996 PMENU menutmp;
3997 UINT NextCol;
3998
3999 TRACE("MenuKeyRight called, cur %p, top %p.\n",
4000 pmt->CurrentMenu, pmt->TopMenu);
4001
4002 if ((pmt->TopMenu->fFlags & MNF_POPUP) || (pmt->CurrentMenu != pmt->TopMenu))
4003 {
4004 /* If already displaying a popup, try to display sub-popup */
4005
4006 menutmp = pmt->CurrentMenu;
4007 pmt->CurrentMenu = MENU_ShowSubPopup(pmt->OwnerWnd, menutmp, TRUE, Flags);
4008
4009 /* if subpopup was displayed then we are done */
4010 if (menutmp != pmt->CurrentMenu) return;
4011 }
4012
4013 /* Check to see if there's another column */
4014 if ( (NextCol = MENU_GetStartOfNextColumn(pmt->CurrentMenu)) != NO_SELECTED_ITEM)
4015 {
4016 TRACE("Going to %d.\n", NextCol);
4017 MENU_SelectItem(pmt->OwnerWnd, pmt->CurrentMenu, NextCol, TRUE, 0);
4018 return;
4019 }
4020
4021 if (!(pmt->TopMenu->fFlags & MNF_POPUP)) /* menu bar tracking */
4022 {
4023 if (pmt->CurrentMenu != pmt->TopMenu)
4024 {
4026 menutmp = pmt->CurrentMenu = pmt->TopMenu;
4027 }
4028 else
4029 {
4030 menutmp = NULL;
4031 }
4032
4033 /* try to move to the next item */
4034 if ( !MENU_DoNextMenu(pmt, VK_RIGHT, Flags))
4036
4037 if ( menutmp || pmt->TrackFlags & TF_SUSPENDPOPUP )
4038 {
4039 if ( !MENU_SuspendPopup(pmt, msg) )
4041 }
4042 }
4043}
static UINT MENU_GetStartOfNextColumn(PMENU menu)
Definition: menu.c:437
#define ITEM_NEXT
Definition: menu.c:93

Referenced by MENU_TrackMenu().

◆ MENU_MenuBarCalcSize()

static void MENU_MenuBarCalcSize ( HDC  hdc,
LPRECT  lprect,
PMENU  lppop,
PWND  pwndOwner 
)
static

Definition at line 2101 of file menu.c.

2102{
2103 ITEM *lpitem;
2104 UINT start, i, helpPos;
2105 int orgX, orgY, maxY;
2106
2107 if ((lprect == NULL) || (lppop == NULL)) return;
2108 if (lppop->cItems == 0) return;
2109 //TRACE("lprect %p %s\n", lprect, wine_dbgstr_rect( lprect));
2110 lppop->cxMenu = lprect->right - lprect->left;
2111 lppop->cyMenu = 0;
2112 maxY = lprect->top;
2113 start = 0;
2114 helpPos = ~0U;
2115 lppop->cxTextAlign = 0;
2116 while (start < lppop->cItems)
2117 {
2118 lpitem = &lppop->rgItems[start];
2119 orgX = lprect->left;
2120 orgY = maxY;
2121
2122 /* Parse items until line break or end of menu */
2123 for (i = start; i < lppop->cItems; i++, lpitem++)
2124 {
2125 if ((helpPos == ~0U) && (lpitem->fType & MF_RIGHTJUSTIFY)) helpPos = i;
2126 if ((i != start) &&
2127 (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
2128
2129 TRACE("calling MENU_CalcItemSize org=(%d, %d)\n", orgX, orgY );
2130 //debug_print_menuitem (" item: ", lpitem, "");
2131 //MENU_CalcItemSize( hdc, lpitem, pwndOwner, orgX, orgY, TRUE, lppop );
2132 MENU_CalcItemSize(hdc, lpitem, lppop, pwndOwner, orgX, orgY, TRUE, FALSE);
2133
2134 if (lpitem->cxItem > lprect->right)
2135 {
2136 if (i != start) break;
2137 else lpitem->cxItem = lprect->right;
2138 }
2139 maxY = max( maxY, lpitem->cyItem );
2140 orgX = lpitem->cxItem;
2141 }
2142
2143 /* Finish the line (set all items to the largest height found) */
2144
2145/* FIXME: Is this really needed? */ /*NO! it is not needed, why make the
2146 HBMMENU_MBAR_CLOSE, MINIMIZE & RESTORE, look the same size as the menu bar! */
2147#if 0
2148 while (start < i) lppop->rgItems[start++].cyItem = maxY;
2149#endif
2150 start = i; /* This works! */
2151 }
2152
2153 lprect->bottom = maxY + 1;
2154 lppop->cyMenu = lprect->bottom - lprect->top;
2155
2156 /* Flush right all items between the MF_RIGHTJUSTIFY and */
2157 /* the last item (if several lines, only move the last line) */
2158 if (helpPos == ~0U) return;
2159 lpitem = &lppop->rgItems[lppop->cItems-1];
2160 orgY = lpitem->yItem;
2161 orgX = lprect->right;
2162 for (i = lppop->cItems - 1; i >= helpPos; i--, lpitem--) {
2163 if (lpitem->yItem != orgY) break; /* Other line */
2164 if (lpitem->cxItem >= orgX) break; /* Too far right already */
2165 lpitem->xItem += orgX - lpitem->cxItem;
2166 lpitem->cxItem = orgX;
2167 orgX = lpitem->xItem;
2168 }
2169}
#define U(x)
Definition: wordpad.c:45
GLuint start
Definition: gl.h:1545
static void FASTCALL MENU_CalcItemSize(HDC hdc, PITEM lpitem, PMENU Menu, PWND pwndOwner, INT orgX, INT orgY, BOOL menuBar, BOOL textandbmp)
Definition: menu.c:1825
#define MF_RIGHTJUSTIFY
Definition: winuser.h:144

Referenced by IntDrawMenuBarTemp(), and MENU_DrawMenuBar().

◆ MENU_MouseMove()

static BOOL FASTCALL MENU_MouseMove ( MTRACKER pmt,
PMENU  PtMenu,
UINT  Flags 
)
static

Definition at line 3692 of file menu.c.

3693{
3695
3696 if ( PtMenu )
3697 MENU_FindItemByCoords( PtMenu, pmt->Pt, &Index );
3698
3699 if (Index == NO_SELECTED_ITEM)
3700 {
3702 }
3703 else if (PtMenu->iItem != Index)
3704 {
3705 MENU_SwitchTracking(pmt, PtMenu, Index, Flags);
3706 pmt->CurrentMenu = MENU_ShowSubPopup(pmt->OwnerWnd, PtMenu, FALSE, Flags);
3707 }
3708 return TRUE;
3709}
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by MENU_TrackMenu().

◆ MENU_MoveRect()

static BOOL MENU_MoveRect ( UINT  flags,
INT x,
INT y,
INT  width,
INT  height,
const RECT pExclude,
PMONITOR  monitor 
)
static

Definition at line 2888 of file menu.c.

2889{
2890 /* Figure out if we should move vertical or horizontal */
2891 if (flags & TPM_VERTICAL)
2892 {
2893 /* Move in the vertical direction: TPM_BOTTOMALIGN means drop it above, otherways drop it below */
2894 if (flags & TPM_BOTTOMALIGN)
2895 {
2896 if (pExclude->top - height >= monitor->rcMonitor.top)
2897 {
2898 *y = pExclude->top - height;
2899 return TRUE;
2900 }
2901 }
2902 else
2903 {
2904 if (pExclude->bottom + height < monitor->rcMonitor.bottom)
2905 {
2906 *y = pExclude->bottom;
2907 return TRUE;
2908 }
2909 }
2910 }
2911 else
2912 {
2913 /* Move in the horizontal direction: TPM_RIGHTALIGN means drop it to the left, otherways go right */
2914 if (flags & TPM_RIGHTALIGN)
2915 {
2916 if (pExclude->left - width >= monitor->rcMonitor.left)
2917 {
2918 *x = pExclude->left - width;
2919 return TRUE;
2920 }
2921 }
2922 else
2923 {
2924 if (pExclude->right + width < monitor->rcMonitor.right)
2925 {
2926 *x = pExclude->right;
2927 return TRUE;
2928 }
2929 }
2930 }
2931 return FALSE;
2932}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
RECT rcMonitor
Definition: monitor.h:18

Referenced by MENU_ShowPopup().

◆ MENU_MoveSelection()

static void FASTCALL MENU_MoveSelection ( PWND  pwndOwner,
PMENU  menu,
INT  offset 
)
static

Definition at line 3231 of file menu.c.

3232{
3233 INT i;
3234
3235 TRACE("pwnd=%x menu=%x off=0x%04x\n", pwndOwner, menu, offset);
3236
3237 if ((!menu) || (!menu->rgItems)) return;
3238
3239 if ( menu->iItem != NO_SELECTED_ITEM )
3240 {
3241 if ( menu->cItems == 1 )
3242 return;
3243 else
3244 for (i = menu->iItem + offset ; i >= 0 && i < menu->cItems
3245 ; i += offset)
3246 if (!(menu->rgItems[i].fType & MF_SEPARATOR))
3247 {
3248 MENU_SelectItem( pwndOwner, menu, i, TRUE, 0 );
3249 return;
3250 }
3251 }
3252
3253 for ( i = (offset > 0) ? 0 : menu->cItems - 1;
3254 i >= 0 && i < menu->cItems ; i += offset)
3255 if (!(menu->rgItems[i].fType & MF_SEPARATOR))
3256 {
3257 MENU_SelectItem( pwndOwner, menu, i, TRUE, 0 );
3258 return;
3259 }
3260}
GLintptr offset
Definition: glext.h:5920

Referenced by MENU_KeyLeft(), MENU_KeyRight(), MENU_ShowSubPopup(), MENU_TrackKbdMenuBar(), and MENU_TrackMenu().

◆ MENU_PopupMenuCalcSize()

static void FASTCALL MENU_PopupMenuCalcSize ( PMENU  Menu,
PWND  WndOwner 
)
static

Definition at line 2012 of file menu.c.

2013{
2014 PITEM lpitem;
2015 HDC hdc;
2016 int start, i;
2017 int orgX, orgY, maxX, maxTab, maxTabWidth, maxHeight;
2018 BOOL textandbmp = FALSE;
2019
2020 Menu->cxMenu = Menu->cyMenu = 0;
2021 if (Menu->cItems == 0) return;
2022
2024
2026
2027 start = 0;
2028 maxX = 0;
2029
2030 Menu->cxTextAlign = 0;
2031
2032 while (start < Menu->cItems)
2033 {
2034 lpitem = &Menu->rgItems[start];
2035 orgX = maxX;
2036 if( lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))
2037 orgX += MENU_COL_SPACE;
2038 orgY = 0;
2039
2040 maxTab = maxTabWidth = 0;
2041 /* Parse items until column break or end of menu */
2042 for (i = start; i < Menu->cItems; i++, lpitem++)
2043 {
2044 if (i != start &&
2045 (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
2046
2047 MENU_CalcItemSize(hdc, lpitem, Menu, WndOwner, orgX, orgY, FALSE, textandbmp);
2048 maxX = max(maxX, lpitem->cxItem);
2049 orgY = lpitem->cyItem;
2050 if (IS_STRING_ITEM(lpitem->fType) && lpitem->dxTab )
2051 {
2052 maxTab = max( maxTab, lpitem->dxTab );
2053 maxTabWidth = max(maxTabWidth, lpitem->cxItem - lpitem->dxTab);
2054 }
2055 if( lpitem->Xlpstr && lpitem->hbmp) textandbmp = TRUE;
2056 }
2057
2058 /* Finish the column (set all items to the largest width found) */
2059 maxX = max( maxX, maxTab + maxTabWidth );
2060 for (lpitem = &Menu->rgItems[start]; start < i; start++, lpitem++)
2061 {
2062 lpitem->cxItem = maxX;
2063 if (IS_STRING_ITEM(lpitem->fType) && lpitem->dxTab)
2064 lpitem->dxTab = maxTab;
2065 }
2066 Menu->cyMenu = max(Menu->cyMenu, orgY);
2067 }
2068
2069 Menu->cxMenu = maxX;
2070 /* if none of the items have both text and bitmap then
2071 * the text and bitmaps are all aligned on the left. If there is at
2072 * least one item with both text and bitmap then bitmaps are
2073 * on the left and texts left aligned with the right hand side
2074 * of the bitmaps */
2075 if( !textandbmp) Menu->cxTextAlign = 0;
2076
2077 /* Adjust popup height if it exceeds maximum */
2078 maxHeight = MENU_GetMaxPopupHeight(Menu);
2079 Menu->iMaxTop = Menu->cyMenu;
2080 if (Menu->cyMenu >= maxHeight)
2081 {
2082 Menu->cyMenu = maxHeight;
2083 Menu->dwArrowsOn = 1;
2084 }
2085 else
2086 {
2087 Menu->dwArrowsOn = 0;
2088 }
2089 UserReleaseDC( 0, hdc, FALSE );
2090}
#define IS_STRING_ITEM(flags)
Definition: menu.c:64
#define MENU_COL_SPACE
Definition: menu.c:71

Referenced by MENU_ShowPopup().

◆ MENU_PtMenu()

static PMENU FASTCALL MENU_PtMenu ( PMENU  menu,
POINT  pt 
)
static

Definition at line 3652 of file menu.c.

3653{
3654 PITEM pItem;
3655 PMENU ret = NULL;
3656
3657 if (!menu) return NULL;
3658
3659 /* try subpopup first (if any) */
3660 if (menu->iItem != NO_SELECTED_ITEM)
3661 {
3662 pItem = menu->rgItems;
3663 if ( pItem ) pItem = &pItem[menu->iItem];
3664 if ( pItem && pItem->spSubMenu && pItem->fState & MF_MOUSESELECT)
3665 {
3666 ret = MENU_PtMenu( pItem->spSubMenu, pt);
3667 }
3668 }
3669
3670 /* check the current window (avoiding WM_HITTEST) */
3671 if (!ret)
3672 {
3673 PWND pWnd = ValidateHwndNoErr(menu->hWnd);
3674 INT ht = GetNCHitEx(pWnd, pt);
3675 if ( menu->fFlags & MNF_POPUP )
3676 {
3677 if (ht != HTNOWHERE && ht != HTERROR) ret = menu;
3678 }
3679 else if (ht == HTSYSMENU)
3680 ret = get_win_sys_menu(menu->hWnd);
3681 else if (ht == HTMENU)
3682 ret = IntGetMenu( menu->hWnd );
3683 }
3684 return ret;
3685}
static const struct newhuff ht[]
Definition: huffman.h:296
static PMENU FASTCALL MENU_PtMenu(PMENU menu, POINT pt)
Definition: menu.c:3652
DWORD FASTCALL GetNCHitEx(PWND pWnd, POINT pt)
Definition: nonclient.c:1985
#define HTERROR
Definition: winuser.h:2491
#define HTMENU
Definition: winuser.h:2499
#define HTNOWHERE
Definition: winuser.h:2493

Referenced by MENU_PtMenu(), and MENU_TrackMenu().

◆ MENU_SelectItem()

static void FASTCALL MENU_SelectItem ( PWND  pwndOwner,
PMENU  menu,
UINT  wIndex,
BOOL  sendMenuSelect,
PMENU  topmenu 
)
static

Definition at line 3144 of file menu.c.

3146{
3147 HDC hdc;
3148 PWND pWnd;
3149
3150 TRACE("M_SI: owner=%p menu=%p index=0x%04x select=0x%04x\n", pwndOwner, menu, wIndex, sendMenuSelect);
3151
3152 if (!menu || !menu->cItems) return;
3153
3154 pWnd = ValidateHwndNoErr(menu->hWnd);
3155
3156 if (!pWnd) return;
3157
3158 if (menu->iItem == wIndex) return;
3159
3160 if (menu->fFlags & MNF_POPUP)
3161 hdc = UserGetDCEx(pWnd, 0, DCX_USESTYLE);
3162 else
3163 hdc = UserGetDCEx(pWnd, 0, DCX_CACHE | DCX_WINDOW);
3164
3165 if (!top_popup) {
3166 top_popup = menu->hWnd; //pPopupMenu->spwndActivePopup or
3167 //pPopupMenu->fIsTrackPopup set pPopupMenu->spwndPopupMenu;
3168 top_popup_hmenu = UserHMGetHandle(menu); //pPopupMenu->spmenu
3169 }
3170
3172
3173 /* Clear previous highlighted item */
3174 if (menu->iItem != NO_SELECTED_ITEM)
3175 {
3176 menu->rgItems[menu->iItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
3177 MENU_DrawMenuItem(pWnd, menu, pwndOwner, hdc, &menu->rgItems[menu->iItem],
3178 menu->cyMenu, !(menu->fFlags & MNF_POPUP),
3179 ODA_SELECT);
3180 }
3181
3182 /* Highlight new item (if any) */
3183 menu->iItem = wIndex;
3184 if (menu->iItem != NO_SELECTED_ITEM)
3185 {
3186 if (!(menu->rgItems[wIndex].fType & MF_SEPARATOR))
3187 {
3188 menu->rgItems[wIndex].fState |= MF_HILITE;
3189 MENU_EnsureMenuItemVisible(menu, wIndex, hdc);
3190 MENU_DrawMenuItem(pWnd, menu, pwndOwner, hdc,
3191 &menu->rgItems[wIndex], menu->cyMenu, !(menu->fFlags & MNF_POPUP), ODA_SELECT);
3192 }
3193 if (sendMenuSelect)
3194 {
3195 ITEM *ip = &menu->rgItems[menu->iItem];
3196 WPARAM wParam = MAKEWPARAM( ip->spSubMenu ? wIndex : ip->wID,
3197 ip->fType | ip->fState |
3198 (ip->spSubMenu ? MF_POPUP : 0) |
3199 (menu->fFlags & MNF_SYSMENU ? MF_SYSMENU : 0 ) );
3200
3202 }
3203 }
3204 else if (sendMenuSelect)
3205 {
3206 if (topmenu)
3207 {
3208 int pos;
3209 pos = MENU_FindSubMenu(&topmenu, menu);
3210 if (pos != NO_SELECTED_ITEM)
3211 {
3212 ITEM *ip = &topmenu->rgItems[pos];
3213 WPARAM wParam = MAKEWPARAM( Pos, ip->fType | ip->fState |
3214 (ip->spSubMenu ? MF_POPUP : 0) |
3215 (topmenu->fFlags & MNF_SYSMENU ? MF_SYSMENU : 0 ) );
3216
3218 }
3219 }
3220 }
3221 UserReleaseDC(pWnd, hdc, FALSE);
3222}
#define DCX_USESTYLE
Definition: GetDCEx.c:10
WPARAM wParam
Definition: combotst.c:138
Definition: dhcpd.h:62
void MENU_EnsureMenuItemVisible(PMENU lppop, UINT wIndex, HDC hdc)
Definition: menu.c:3102
#define DCX_WINDOW
Definition: winuser.h:2132
#define ODA_SELECT
Definition: winuser.h:2562
#define WM_MENUSELECT
Definition: winuser.h:1766

Referenced by IntHiliteMenuItem(), MENU_DoNextMenu(), MENU_HideSubPopups(), MENU_KeyLeft(), MENU_KeyRight(), MENU_MouseMove(), MENU_MoveSelection(), MENU_SwitchTracking(), MENU_TrackKbdMenuBar(), and MENU_TrackMenu().

◆ MENU_ShowPopup()

static BOOL FASTCALL MENU_ShowPopup ( PWND  pwndOwner,
PMENU  menu,
UINT  id,
UINT  flags,
INT  x,
INT  y,
const RECT pExclude 
)
static

Definition at line 2939 of file menu.c.

2941{
2942 INT width, height;
2943 POINT ptx;
2944 PMONITOR monitor;
2945 PWND pWnd;
2947 BOOL bIsPopup = (flags & TPM_POPUPMENU) != 0;
2948
2949 TRACE("owner=%p menu=%p id=0x%04x x=0x%04x y=0x%04x\n",
2950 pwndOwner, menu, id, x, y);
2951
2952 if (menu->iItem != NO_SELECTED_ITEM)
2953 {
2954 menu->rgItems[menu->iItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
2955 menu->iItem = NO_SELECTED_ITEM;
2956 }
2957
2958#if SHOW_DEBUGRECT
2959 if (pExclude)
2960 DebugRect(pExclude, RGB(255, 0, 0));
2961#endif
2962
2963 menu->dwArrowsOn = 0;
2964 MENU_PopupMenuCalcSize(menu, pwndOwner);
2965
2966 /* adjust popup menu pos so that it fits within the desktop */
2967
2970
2971 if (flags & TPM_LAYOUTRTL)
2973
2974 if (flags & TPM_RIGHTALIGN)
2975 x -= width;
2976 if (flags & TPM_CENTERALIGN)
2977 x -= width / 2;
2978
2979 if (flags & TPM_BOTTOMALIGN)
2980 y -= height;
2981 if (flags & TPM_VCENTERALIGN)
2982 y -= height / 2;
2983
2984 /* FIXME: should use item rect */
2985 ptx.x = x;
2986 ptx.y = y;
2987#if SHOW_DEBUGRECT
2988 DebugPoint(x, y, RGB(0, 0, 255));
2989#endif
2990 monitor = UserMonitorFromPoint( ptx, MONITOR_DEFAULTTONEAREST );
2991
2992 /* We are off the right side of the screen */
2993 if (x + width > monitor->rcMonitor.right)
2994 {
2995 /* Position menu at right edge of the screen */
2996 x = monitor->rcMonitor.right - width;
2997 }
2998
2999 /* We are off the left side of the screen */
3000 if (x < monitor->rcMonitor.left)
3001 {
3002 /* Position menu at left edge of the screen */
3003 x = 0;
3004
3005 if (x < monitor->rcMonitor.left || x >= monitor->rcMonitor.right || bIsPopup)
3006 x = monitor->rcMonitor.left;
3007 }
3008
3009 /* Same here, but then the top */
3010 if (y < monitor->rcMonitor.top)
3011 {
3012 y += height;
3013
3014 if (y < monitor->rcMonitor.top || y >= monitor->rcMonitor.bottom || bIsPopup)
3015 y = monitor->rcMonitor.top;
3016 }
3017
3018 /* And the bottom */
3019 if (y + height > monitor->rcMonitor.bottom)
3020 {
3021 if ((y - height) < monitor->rcMonitor.top || y >= monitor->rcMonitor.bottom)
3022 y = monitor->rcMonitor.bottom - height;
3023 else
3024 {
3027 if (adjHgt >= monitor->rcMonitor.bottom)
3028 y -= height;
3029 else
3030 y = adjHgt - height;
3031 }
3032 }
3033
3034 if (pExclude)
3035 {
3036 RECT Cleaned;
3037
3038 if (RECTL_bIntersectRect(&Cleaned, pExclude, &monitor->rcMonitor) &&
3039 RECTL_Intersect(&Cleaned, x, y, width, height))
3040 {
3041 UINT flag_mods[] = {
3042 0, /* First try the 'normal' way */
3043 TPM_BOTTOMALIGN | TPM_RIGHTALIGN, /* Then try the opposite side */
3044 TPM_VERTICAL, /* Then swap horizontal / vertical */
3045 TPM_BOTTOMALIGN | TPM_RIGHTALIGN | TPM_VERTICAL, /* Then the other side again (still swapped hor/ver) */
3046 };
3047
3048 UINT n;
3049 for (n = 0; n < RTL_NUMBER_OF(flag_mods); ++n)
3050 {
3051 INT tx = x;
3052 INT ty = y;
3053
3054 /* Try to move a bit around */
3055 if (MENU_MoveRect(flags ^ flag_mods[n], &tx, &ty, width, height, &Cleaned, monitor) &&
3056 !RECTL_Intersect(&Cleaned, tx, ty, width, height))
3057 {
3058 x = tx;
3059 y = ty;
3060 break;
3061 }
3062 }
3063 /* If none worked, we go with the original x/y */
3064 }
3065 }
3066
3067#if SHOW_DEBUGRECT
3068 {
3069 RECT rr = {x, y, x + width, y + height};
3070 DebugRect(&rr, RGB(0, 255, 0));
3071 }
3072#endif
3073
3074 pWnd = ValidateHwndNoErr( menu->hWnd );
3075
3076 if (!pWnd)
3077 {
3078 ERR("menu->hWnd bad hwnd %p\n",menu->hWnd);
3079 return FALSE;
3080 }
3081
3082 if (!top_popup) {
3083 top_popup = menu->hWnd;
3085 }
3086
3087 /* Display the window */
3088 UserRefObjectCo(pWnd, &Ref);
3090
3092
3093 IntNotifyWinEvent(EVENT_SYSTEM_MENUPOPUPSTART, pWnd, OBJID_CLIENT, CHILDID_SELF, 0);
3094 UserDerefObjectCo(pWnd);
3095
3096 return TRUE;
3097}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define RGB(r, g, b)
Definition: precomp.h:71
GLbyte ty
Definition: glext.h:8756
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1792
VOID FASTCALL co_IntUpdateWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
Definition: painting.c:519
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
static BOOL RECTL_Intersect(const RECT *pRect, INT x, INT y, UINT width, UINT height)
Definition: menu.c:2880
static BOOL MENU_MoveRect(UINT flags, INT *x, INT *y, INT width, INT height, const RECT *pExclude, PMONITOR monitor)
Definition: menu.c:2888
static void FASTCALL MENU_PopupMenuCalcSize(PMENU Menu, PWND WndOwner)
Definition: menu.c:2012
PMONITOR FASTCALL UserMonitorFromPoint(IN POINT pt, IN DWORD dwFlags)
Definition: monitor.c:481
#define OBJID_CLIENT
Definition: winable.h:19
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define HWND_TOPMOST
Definition: winuser.h:1219
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
#define SWP_SHOWWINDOW
Definition: winuser.h:1259

Referenced by IntTrackPopupMenuEx(), and MENU_ShowSubPopup().

◆ MENU_ShowSubPopup()

static PMENU FASTCALL MENU_ShowSubPopup ( PWND  WndOwner,
PMENU  Menu,
BOOL  SelectFirst,
UINT  Flags 
)
static

Definition at line 3321 of file menu.c.

3322{
3323 RECT Rect, ParentRect;
3324 ITEM *Item;
3325 HDC Dc;
3326 PWND pWnd;
3327
3328 TRACE("owner=%x menu=%p 0x%04x\n", WndOwner, Menu, SelectFirst);
3329
3330 if (!Menu) return Menu;
3331
3332 if (Menu->iItem == NO_SELECTED_ITEM) return Menu;
3333
3334 Item = &Menu->rgItems[Menu->iItem];
3335 if (!(Item->spSubMenu) || (Item->fState & (MF_GRAYED | MF_DISABLED)))
3336 return Menu;
3337
3338 /* message must be sent before using item,
3339 because nearly everything may be changed by the application ! */
3340
3341 /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
3342 if (!(Flags & TPM_NONOTIFY))
3343 {
3345 (WPARAM) UserHMGetHandle(Item->spSubMenu),
3346 MAKELPARAM(Menu->iItem, IS_SYSTEM_MENU(Menu)));
3347 }
3348
3349 Item = &Menu->rgItems[Menu->iItem];
3350 //Rect = ItemInfo.Rect;
3351 Rect.left = Item->xItem;
3352 Rect.top = Item->yItem;
3353 Rect.right = Item->cxItem; // Do this for now......
3354 Rect.bottom = Item->cyItem;
3355
3356 pWnd = ValidateHwndNoErr(Menu->hWnd);
3357
3358 /* Grab the rect of our (entire) parent menu, so we can try to not overlap it */
3359 if (Menu->fFlags & MNF_POPUP)
3360 {
3361 if (!IntGetWindowRect(pWnd, &ParentRect))
3362 {
3363 ERR("No pWnd\n");
3364 ParentRect = Rect;
3365 }
3366
3367 /* Ensure we can slightly overlap our parent */
3368 RECTL_vInflateRect(&ParentRect, -UserGetSystemMetrics(SM_CXEDGE) * 2, 0);
3369 }
3370 else
3371 {
3372 /* Inside the menu bar, we do not want to grab the entire window... */
3373 ParentRect = Rect;
3374 if (pWnd)
3375 RECTL_vOffsetRect(&ParentRect, pWnd->rcWindow.left, pWnd->rcWindow.top);
3376 }
3377
3378 /* correct item if modified as a reaction to WM_INITMENUPOPUP message */
3379 if (!(Item->fState & MF_HILITE))
3380 {
3381 if (Menu->fFlags & MNF_POPUP) Dc = UserGetDCEx(pWnd, NULL, DCX_USESTYLE);
3382 else Dc = UserGetDCEx(pWnd, 0, DCX_CACHE | DCX_WINDOW);
3383
3385
3386 Item->fState |= MF_HILITE;
3387 MENU_DrawMenuItem(pWnd, Menu, WndOwner, Dc, Item, Menu->cyMenu,
3388 !(Menu->fFlags & MNF_POPUP), ODA_DRAWENTIRE);
3389
3390 UserReleaseDC(pWnd, Dc, FALSE);
3391 }
3392
3393 if (!Item->yItem && !Item->xItem && !Item->cyItem && !Item->cxItem)
3394 {
3395 Item->xItem = Rect.left;
3396 Item->yItem = Rect.top;
3397 Item->cxItem = Rect.right; // Do this for now......
3398 Item->cyItem = Rect.bottom;
3399 }
3400 Item->fState |= MF_MOUSESELECT;
3401
3402 if (IS_SYSTEM_MENU(Menu) && !(Menu->fFlags & MNF_POPUP))
3403 {
3404 MENU_InitSysMenuPopup(Item->spSubMenu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
3405
3406 NC_GetSysPopupPos(pWnd, &Rect);
3407 /* Ensure we do not overlap this */
3408 ParentRect = Rect;
3409 if (Flags & TPM_LAYOUTRTL) Rect.left = Rect.right;
3410 Rect.top = Rect.bottom;
3413 }
3414 else
3415 {
3416 IntGetWindowRect(pWnd, &Rect);
3417 if (Menu->fFlags & MNF_POPUP)
3418 {
3419 RECT rc;
3420 rc.left = Item->xItem;
3421 rc.top = Item->yItem;
3422 rc.right = Item->cxItem;
3423 rc.bottom = Item->cyItem;
3424
3425 MENU_AdjustMenuItemRect(Menu, &rc);
3426
3427 /* The first item in the popup menu has to be at the
3428 same y position as the focused menu item */
3429 if(Flags & TPM_LAYOUTRTL)
3431 else
3433
3434 Rect.top += rc.top;
3435 }
3436 else
3437 {
3438 if(Flags & TPM_LAYOUTRTL)
3439 Rect.left += Rect.right - Item->xItem; //ItemInfo.Rect.left;
3440 else
3441 Rect.left += Item->xItem; //ItemInfo.Rect.left;
3442 Rect.top += Item->cyItem; //ItemInfo.Rect.bottom;
3443 Rect.right = Item->cxItem - Item->xItem; //ItemInfo.Rect.right - ItemInfo.Rect.left;
3444 Rect.bottom = Item->cyItem - Item->yItem; //ItemInfo.Rect.bottom - ItemInfo.Rect.top;
3445 }
3446 }
3447
3448 /* Next menu does not need to be shown vertical anymore */
3449 if (Menu->fFlags & MNF_POPUP)
3450 Flags &= (~TPM_VERTICAL);
3451
3452
3453
3454 /* use default alignment for submenus */
3456
3457 MENU_InitPopup( WndOwner, Item->spSubMenu, Flags );
3458
3459 MENU_ShowPopup( WndOwner, Item->spSubMenu, Menu->iItem, Flags,
3460 Rect.left, Rect.top, &ParentRect);
3461 if (SelectFirst)
3462 {
3463 MENU_MoveSelection(WndOwner, Item->spSubMenu, ITEM_NEXT);
3464 }
3465 return Item->spSubMenu;
3466}
void FASTCALL NC_GetSysPopupPos(PWND Wnd, RECT *Rect)
Definition: nonclient.c:117

Referenced by MENU_ButtonDown(), MENU_ExecFocusedItem(), MENU_KeyLeft(), MENU_KeyRight(), MENU_MouseMove(), and MENU_TrackMenu().

◆ MENU_SuspendPopup()

static BOOL FASTCALL MENU_SuspendPopup ( MTRACKER pmt,
UINT  uMsg 
)
static

Definition at line 3877 of file menu.c.

3878{
3879 MSG msg;
3880
3881 msg.hwnd = UserHMGetHandle(pmt->OwnerWnd);
3882
3883 co_IntGetPeekMessage( &msg, 0, uMsg, uMsg, PM_NOYIELD | PM_REMOVE, FALSE);
3884 pmt->TrackFlags |= TF_SKIPREMOVE;
3885
3886 switch( uMsg )
3887 {
3888 case WM_KEYDOWN:
3890 if( msg.message == WM_KEYUP || msg.message == WM_PAINT )
3891 {
3894 if( msg.message == WM_KEYDOWN &&
3895 (msg.wParam == VK_LEFT || msg.wParam == VK_RIGHT))
3896 {
3898 return TRUE;
3899 }
3900 }
3901 break;
3902 }
3903 /* failures go through this */
3904 pmt->TrackFlags &= ~TF_SUSPENDPOPUP;
3905 return FALSE;
3906}
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define TF_SKIPREMOVE
Definition: menu.c:37
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1226
#define WM_PAINT
Definition: winuser.h:1639
#define WM_KEYUP
Definition: winuser.h:1735
#define PM_NOYIELD
Definition: winuser.h:1208
#define PM_REMOVE
Definition: winuser.h:1207
#define WM_KEYDOWN
Definition: winuser.h:1734
#define PM_NOREMOVE
Definition: winuser.h:1206

Referenced by MENU_KeyLeft(), and MENU_KeyRight().

◆ MENU_SwitchTracking()

static void FASTCALL MENU_SwitchTracking ( MTRACKER pmt,
PMENU  PtMenu,
UINT  Index,
UINT  wFlags 
)
static

Definition at line 3533 of file menu.c.

3534{
3535 TRACE("%x menu=%x 0x%04x\n", pmt, PtMenu, Index);
3536
3537 if ( pmt->TopMenu != PtMenu &&
3538 !((PtMenu->fFlags | pmt->TopMenu->fFlags) & MNF_POPUP) )
3539 {
3540 /* both are top level menus (system and menu-bar) */
3543 pmt->TopMenu = PtMenu;
3544 }
3545 else
3546 {
3547 MENU_HideSubPopups(pmt->OwnerWnd, PtMenu, FALSE, wFlags);
3548 }
3549
3550 MENU_SelectItem(pmt->OwnerWnd, PtMenu, Index, TRUE, NULL);
3551}

Referenced by MENU_ButtonDown(), and MENU_MouseMove().

◆ MENU_TrackKbdMenuBar()

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

Definition at line 4516 of file menu.c.

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

Referenced by DefWndHandleSysCommand().

◆ MENU_TrackMenu()

static INT FASTCALL MENU_TrackMenu ( PMENU  pmenu,
UINT  wFlags,
INT  x,
INT  y,
PWND  pwnd 
)
static

Definition at line 4050 of file menu.c.

4052{
4053 MSG msg;
4054 BOOL fRemove;
4055 INT executedMenuId = -1;
4056 MTRACKER mt;
4057 HWND capture_win;
4058 PMENU pmMouse;
4059 BOOL enterIdleSent = FALSE;
4060 BOOL firstClick = TRUE;
4061 PWND pWnd;
4063
4064 if (pti != pwnd->head.pti)
4065 {
4066 ERR("Not the same PTI!!!!\n");
4067 }
4068
4069 mt.TrackFlags = 0;
4070 mt.CurrentMenu = pmenu;
4071 mt.TopMenu = pmenu;
4072 mt.OwnerWnd = pwnd;
4073 mt.Pt.x = x;
4074 mt.Pt.y = y;
4075
4076 TRACE("MTM : hmenu=%p flags=0x%08x (%d,%d) hwnd=%x\n",
4077 UserHMGetHandle(pmenu), wFlags, x, y, UserHMGetHandle(pwnd));
4078
4079 pti->MessageQueue->QF_flags &= ~QF_ACTIVATIONCHANGE;
4080
4081 if (wFlags & TPM_BUTTONDOWN)
4082 {
4083 /* Get the result in order to start the tracking or not */
4084 fRemove = MENU_ButtonDown( &mt, pmenu, wFlags );
4085 fInsideMenuLoop = fRemove;
4086 }
4087
4089
4090 if (wFlags & TPM_POPUPMENU && pmenu->cItems == 0) // Tracking empty popup menu...
4091 {
4093 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4094 co_UserSetCapture(NULL); /* release the capture */
4095 return 0;
4096 }
4097
4098 capture_win = IntGetCapture();
4099
4100 while (fInsideMenuLoop)
4101 {
4103 if (!VerifyMenu( mt.CurrentMenu )) /* sometimes happens if I do a window manager close */
4104 break;
4105
4106 /* we have to keep the message in the queue until it's
4107 * clear that menu loop is not over yet. */
4108
4109 for (;;)
4110 {
4111 if (co_IntGetPeekMessage( &msg, 0, 0, 0, PM_NOREMOVE, FALSE ))
4112 {
4113 if (!IntCallMsgFilter( &msg, MSGF_MENU )) break;
4114 /* remove the message from the queue */
4115 co_IntGetPeekMessage( &msg, 0, msg.message, msg.message, PM_REMOVE, FALSE );
4116 }
4117 else
4118 {
4119 /* ReactOS Checks */
4120 if (!VerifyWnd(mt.OwnerWnd) ||
4122 //pti->MessageQueue->QF_flags & QF_ACTIVATIONCHANGE || // See CORE-17338
4123 capture_win != IntGetCapture() ) // Should not happen, but this is ReactOS...
4124 {
4125 ErrorExit = TRUE; // Do not wait on dead windows, now win test_capture_4 works.
4126 break;
4127 }
4128
4129 if (!enterIdleSent)
4130 {
4132 enterIdleSent = TRUE;
4134 }
4135 co_IntWaitMessage(NULL, 0, 0);
4136 }
4137 }
4138
4139 if (ErrorExit) break; // Gracefully dropout.
4140
4141 /* check if EndMenu() tried to cancel us, by posting this message */
4142 if (msg.message == WM_CANCELMODE)
4143 {
4144 /* we are now out of the loop */
4146
4147 /* remove the message from the queue */
4148 co_IntGetPeekMessage( &msg, 0, msg.message, msg.message, PM_REMOVE, FALSE );
4149
4150 /* break out of internal loop, ala ESCAPE */
4151 break;
4152 }
4153
4154 mt.Pt = msg.pt;
4155
4156 if ( (msg.hwnd == mt.CurrentMenu->hWnd) || ((msg.message!=WM_TIMER) && (msg.message!=WM_SYSTIMER)) )
4157 enterIdleSent=FALSE;
4158
4159 fRemove = FALSE;
4160 if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST))
4161 {
4162 /*
4163 * Use the mouse coordinates in lParam instead of those in the MSG
4164 * struct to properly handle synthetic messages. They are already
4165 * in screen coordinates.
4166 */
4167 mt.Pt.x = (short)LOWORD(msg.lParam);
4168 mt.Pt.y = (short)HIWORD(msg.lParam);
4169
4170 /* Find a menu for this mouse event */
4171 pmMouse = MENU_PtMenu( mt.TopMenu, mt.Pt );
4172
4173 switch(msg.message)
4174 {
4175 /* no WM_NC... messages in captured state */
4176
4177 case WM_RBUTTONDBLCLK:
4178 case WM_RBUTTONDOWN:
4179 if (!(wFlags & TPM_RIGHTBUTTON))
4180 {
4181 if ( msg.message == WM_RBUTTONDBLCLK ) fInsideMenuLoop = FALSE; // Must exit or loop forever!
4182 break;
4183 }
4184 /* fall through */
4185 case WM_LBUTTONDBLCLK:
4186 case WM_LBUTTONDOWN:
4187 {
4188 /* If the message belongs to the menu, removes it from the queue */
4189 /* Else, end menu tracking */
4190 pWnd = ValidateHwndNoErr(mt.TopMenu->hWnd);
4191 /* Don't remove WM_LBUTTONDBLCLK to allow the closing of a window or program */
4192 if (msg.message == WM_LBUTTONDBLCLK && GetNCHitEx(pWnd, mt.Pt) == HTSYSMENU)
4193 fRemove = FALSE;
4194 else
4195 fRemove = MENU_ButtonDown(&mt, pmMouse, wFlags);
4196
4197 fInsideMenuLoop = fRemove;
4198 if (msg.message == WM_RBUTTONDBLCLK)
4199 fInsideMenuLoop = FALSE; // Must exit or loop forever
4200 break;
4201 }
4202
4203 case WM_RBUTTONUP:
4204 if (!(wFlags & TPM_RIGHTBUTTON)) break;
4205 /* fall through */
4206 case WM_LBUTTONUP:
4207 /* Check if a menu was selected by the mouse */
4208 if (pmMouse)
4209 {
4210 pWnd = ValidateHwndNoErr(mt.TopMenu->hWnd);
4211 /* Exit system menu if system icon is clicked a second time */
4212 if (!firstClick && GetNCHitEx(pWnd, mt.Pt) == HTSYSMENU)
4213 {
4214 fRemove = TRUE;
4216 }
4217 else
4218 {
4219 /* End the loop if executedMenuId is an item ID */
4220 /* or if the job was done (executedMenuId = 0). */
4221 executedMenuId = MENU_ButtonUp( &mt, pmMouse, wFlags);
4222 fRemove = (executedMenuId != -1);
4223 fInsideMenuLoop = !fRemove;
4224 firstClick = FALSE;
4225 }
4226 }
4227 /* No menu was selected by the mouse */
4228 /* if the function was called by TrackPopupMenu, continue
4229 with the menu tracking. If not, stop it */
4230 else
4232
4233 break;
4234
4235 case WM_MOUSEMOVE:
4236 /* the selected menu item must be changed every time */
4237 /* the mouse moves. */
4238
4239 if (pmMouse)
4240 fInsideMenuLoop |= MENU_MouseMove( &mt, pmMouse, wFlags );
4241
4242 } /* switch(msg.message) - mouse */
4243 }
4244 else if ((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST))
4245 {
4246 fRemove = TRUE; /* Keyboard messages are always removed */
4247 switch(msg.message)
4248 {
4249 case WM_KEYDOWN:
4250 case WM_SYSKEYDOWN:
4251 switch(msg.wParam)
4252 {
4253 case VK_MENU:
4254 case VK_F10:
4256 break;
4257
4258 case VK_HOME:
4259 case VK_END:
4262 break;
4263
4264 case VK_UP:
4265 case VK_DOWN: /* If on menu bar, pull-down the menu */
4266 if (!(mt.CurrentMenu->fFlags & MNF_POPUP))
4268 else /* otherwise try to move selection */
4270 break;
4271
4272 case VK_LEFT:
4273 MENU_KeyLeft( &mt, wFlags, msg.message );
4274 break;
4275
4276 case VK_RIGHT:
4277 MENU_KeyRight( &mt, wFlags, msg.message );
4278 break;
4279
4280 case VK_ESCAPE:
4282 break;
4283
4284 case VK_F1:
4285 {
4286 HELPINFO hi;
4287 hi.cbSize = sizeof(HELPINFO);
4290 hi.iCtrlId = 0;
4291 else
4292 hi.iCtrlId = pmenu->rgItems[mt.CurrentMenu->iItem].wID;
4294 hi.dwContextId = pmenu->dwContextHelpId;
4295 hi.MousePos = msg.pt;
4296 co_IntSendMessage( UserHMGetHandle(pwnd), WM_HELP, 0, (LPARAM)&hi);
4297 break;
4298 }
4299
4300 default:
4302 break;
4303 }
4304 break; /* WM_KEYDOWN */
4305
4306 case WM_CHAR:
4307 case WM_SYSCHAR:
4308 {
4309 UINT pos;
4310 BOOL fEndMenu;
4311
4312 if (msg.wParam == L'\r' || msg.wParam == L' ')
4313 {
4314 executedMenuId = MENU_ExecFocusedItem(&mt, mt.CurrentMenu, wFlags);
4315 fEndMenu = (executedMenuId != -2);
4316 fInsideMenuLoop = !fEndMenu;
4317 break;
4318 }
4319
4320 /* Hack to avoid control chars. */
4321 /* We will find a better way real soon... */
4322 if (msg.wParam < 32) break;
4323
4325
4326 if (pos == (UINT)-2) fInsideMenuLoop = FALSE;
4327 else if (pos == (UINT)-1) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0);
4328 else
4329 {
4331 executedMenuId = MENU_ExecFocusedItem(&mt, mt.CurrentMenu, wFlags);
4332 fEndMenu = (executedMenuId != -2);
4333 fInsideMenuLoop = !fEndMenu;
4334 }
4335 }
4336 break;
4337 } /* switch(msg.message) - kbd */
4338 }
4339 else
4340 {
4341 co_IntGetPeekMessage( &msg, 0, msg.message, msg.message, PM_REMOVE, FALSE );
4343 continue;
4344 }
4345
4346 if (fInsideMenuLoop) fRemove = TRUE;
4347
4348 /* finally remove message from the queue */
4349
4350 if (fRemove && !(mt.TrackFlags & TF_SKIPREMOVE) )
4351 co_IntGetPeekMessage( &msg, 0, msg.message, msg.message, PM_REMOVE, FALSE );
4352 else mt.TrackFlags &= ~TF_SKIPREMOVE;
4353 }
4354
4356 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4357 co_UserSetCapture(NULL); /* release the capture */
4358
4359 /* If dropdown is still painted and the close box is clicked on
4360 then the menu will be destroyed as part of the DispatchMessage above.
4361 This will then invalidate the menu handle in mt.hTopMenu. We should
4362 check for this first. */
4363 if ( VerifyMenu( mt.TopMenu ) )
4364 {
4365 if (VerifyWnd(mt.OwnerWnd))
4366 {
4368
4369 if (mt.TopMenu->fFlags & MNF_POPUP)
4370 {
4371 PWND pwndTM = ValidateHwndNoErr(mt.TopMenu->hWnd);
4372 if (pwndTM)
4373 {
4374 IntNotifyWinEvent(EVENT_SYSTEM_MENUPOPUPEND, pwndTM, OBJID_CLIENT, CHILDID_SELF, 0);
4375
4376 co_UserDestroyWindow(pwndTM);
4377 }
4378 mt.TopMenu->hWnd = NULL;
4379
4380 if (!(wFlags & TPM_NONOTIFY))
4381 {
4384 }
4385 }
4388 }
4389
4390 /* Reset the variable for hiding menu */
4391 mt.TopMenu->TimeToHide = FALSE;
4392 }
4393
4395 /* The return value is only used by TrackPopupMenu */
4396 if (!(wFlags & TPM_RETURNCMD)) return TRUE;
4397 if (executedMenuId == -1) executedMenuId = 0;
4398 return executedMenuId;
4399}
#define WM_SYSTIMER
Definition: comctl32.h:125
#define ERROR_SUCCESS
Definition: deptool.c:10
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
HWND APIENTRY IntGetCapture(VOID)
Definition: focus.c:1443
Definition: menu.c:79
THRDESKHEAD head
Definition: ntuser.h:695
POINT MousePos
Definition: winuser.h:3393
int iCtrlId
Definition: winuser.h:3390
DWORD_PTR dwContextId
Definition: winuser.h:3392
HANDLE hItemHandle
Definition: winuser.h:3391
int iContextType
Definition: winuser.h:3389
UINT cbSize
Definition: winuser.h:3388
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags)
Definition: keyboard.c:1276
static BOOL FASTCALL MENU_MouseMove(MTRACKER *pmt, PMENU PtMenu, UINT Flags)
Definition: menu.c:3692
static void FASTCALL MENU_KeyRight(MTRACKER *pmt, UINT Flags, UINT msg)
Definition: menu.c:3994
#define TPM_BUTTONDOWN
Definition: menu.c:89
static INT FASTCALL MENU_ButtonUp(MTRACKER *pmt, PMENU PtMenu, UINT Flags)
Definition: menu.c:3603
static BOOL FASTCALL MENU_ButtonDown(MTRACKER *pmt, PMENU PtMenu, UINT Flags)
Definition: menu.c:3558
static void FASTCALL MENU_KeyLeft(MTRACKER *pmt, UINT Flags, UINT msg)
Definition: menu.c:3946
static BOOL FASTCALL MENU_KeyEscape(MTRACKER *pmt, UINT Flags)
Definition: menu.c:3913
BOOL FASTCALL IntCallMsgFilter(LPMSG lpmsg, INT code)
Definition: message.c:2190
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:890
BOOL FASTCALL co_IntWaitMessage(PWND Window, UINT MsgFilterMin, UINT MsgFilterMax)
Definition: message.c:1180
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:88
#define WM_MOUSEFIRST
Definition: winuser.h:1793
#define WM_MOUSELAST
Definition: winuser.h:1820
#define HELPINFO_MENUITEM
Definition: winuser.h:1182
#define VK_F10
Definition: winuser.h:2283
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1797
#define WM_KEYFIRST
Definition: winuser.h:1733
#define WM_RBUTTONUP
Definition: winuser.h:1799
#define VK_UP
Definition: winuser.h:2244
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1800
#define WM_MOUSEMOVE
Definition: winuser.h:1794
#define WM_LBUTTONDOWN
Definition: winuser.h:1795
#define VK_F1
Definition: winuser.h:2274
#define WM_RBUTTONDOWN
Definition: winuser.h:1798
#define WM_SYSCHAR
Definition: winuser.h:1740
#define WM_TIMER
Definition: winuser.h:1761
#define VK_END
Definition: winuser.h:2241
#define VK_HOME
Definition: winuser.h:2242
#define MSGF_MENU
Definition: winuser.h:1186
struct tagHELPINFO HELPINFO
#define WM_LBUTTONUP
Definition: winuser.h:1796
#define WM_CHAR
Definition: winuser.h:1736
#define VK_DOWN
Definition: winuser.h:2246
#define WM_KEYLAST
Definition: winuser.h:1747
#define VK_ESCAPE
Definition: winuser.h:2233
#define WM_ENTERIDLE
Definition: winuser.h:1768
#define WM_SYSKEYDOWN
Definition: winuser.h:1738
#define VK_MENU
Definition: winuser.h:2223

Referenced by IntTrackPopupMenuEx(), MENU_TrackKbdMenuBar(), and MENU_TrackMouseMenuBar().

◆ MENU_TrackMouseMenuBar()

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

Definition at line 4486 of file menu.c.

4487{
4488 PMENU pMenu = (ht == HTSYSMENU) ? IntGetSystemMenu(pWnd, FALSE) : IntGetMenu( UserHMGetHandle(pWnd) ); // See 74276 and CORE-12801
4490
4491 TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", pWnd, ht, pt.x, pt.y);
4492
4493 if (pWnd->ExStyle & WS_EX_LAYOUTRTL) wFlags |= TPM_LAYOUTRTL;
4494 if (VerifyMenu(pMenu))
4495 {
4496 /* map point to parent client coordinates */
4499 {
4501 }
4502
4503 MENU_InitTracking(pWnd, pMenu, FALSE, wFlags);
4504 /* fetch the window menu again, it may have changed */
4505 pMenu = (ht == HTSYSMENU) ? get_win_sys_menu( UserHMGetHandle(pWnd) ) : IntGetMenu( UserHMGetHandle(pWnd) );
4506 MENU_TrackMenu(pMenu, wFlags, pt.x, pt.y, pWnd);
4508 }
4509}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:213
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1403
PMENU FASTCALL IntGetSystemMenu(PWND Window, BOOL bRevert)
Definition: menu.c:5409

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 GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
VOID FASTCALL co_IntSetupOBM(VOID)
Definition: callback.c:1180
#define FW_BOLD
Definition: wingdi.h:378
#define FW_HEAVY
Definition: wingdi.h:381

Referenced by ClientThreadSetupHelper(), and co_IntInitializeDesktopGraphics().

◆ NtUserCalcMenuBar()

DWORD APIENTRY NtUserCalcMenuBar ( HWND  hwnd,
DWORD  leftBorder,
DWORD  rightBorder,
DWORD  top,
LPRECT  prc 
)

Definition at line 5564 of file menu.c.

5570{
5571 HDC hdc;
5572 PWND Window;
5573 RECT Rect;
5574 DWORD ret;
5575
5577
5579 {
5580 UserLeave();
5582 return 0;
5583 }
5584
5586 if (!hdc)
5587 {
5588 UserLeave();
5589 return 0;
5590 }
5591
5592 Rect.left = leftBorder;
5593 Rect.right = Window->rcWindow.right - Window->rcWindow.left - rightBorder;
5594 Rect.top = top;
5595 Rect.bottom = 0;
5596
5598
5599 UserReleaseDC( 0, hdc, FALSE );
5600
5601 UserLeave();
5602 return ret;
5603}
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
UINT MENU_DrawMenuBar(HDC hDC, LPRECT lprect, PWND pWnd, BOOL suppress_draw)
Definition: menu.c:2742

◆ NtUserCheckMenuItem()

DWORD APIENTRY NtUserCheckMenuItem ( HMENU  hMenu,
UINT  uIDCheckItem,
UINT  uCheck 
)

Definition at line 5609 of file menu.c.

5613{
5614 PMENU Menu;
5615 DWORD Ret = (DWORD)-1;
5616
5617 TRACE("Enter NtUserCheckMenuItem\n");
5619
5620 Menu = UserGetMenuObject(hMenu);
5621 if (Menu)
5622 {
5623 Ret = IntCheckMenuItem(Menu, uIDCheckItem, uCheck);
5624 }
5625
5626 UserLeave();
5627 TRACE("Leave NtUserCheckMenuItem, ret=%lu\n", Ret);
5628 return Ret;
5629}
DWORD FASTCALL IntCheckMenuItem(PMENU MenuObject, UINT uIDCheckItem, UINT uCheck)
Definition: menu.c:1259

Referenced by CheckMenuItem().

◆ NtUserDeleteMenu()

BOOL APIENTRY NtUserDeleteMenu ( HMENU  hMenu,
UINT  uPosition,
UINT  uFlags 
)

Definition at line 5635 of file menu.c.

5639{
5640 PMENU Menu;
5641 BOOL Ret = FALSE;
5642
5643 TRACE("Enter NtUserDeleteMenu\n");
5645
5646 Menu = UserGetMenuObject(hMenu);
5647 if (Menu)
5648 {
5649 Ret = IntRemoveMenuItem(Menu, uPosition, uFlags, TRUE);
5650 }
5651
5652 UserLeave();
5653 TRACE("Leave NtUserDeleteMenu, ret=%i\n", Ret);
5654 return Ret;
5655}

Referenced by DeleteMenu().

◆ NtUserDestroyMenu()

BOOL APIENTRY NtUserDestroyMenu ( HMENU  hMenu)

Definition at line 5842 of file menu.c.

5844{
5845 PMENU Menu;
5846 BOOL Ret = FALSE;
5847
5848 TRACE("Enter NtUserDestroyMenu\n");
5850
5851 if(!(Menu = UserGetMenuObject(hMenu)))
5852 {
5853 goto Exit; // Return FALSE
5854 }
5855 if (Menu->head.rpdesk != gptiCurrent->rpdesk)
5856 {
5858 goto Exit; // Return FALSE
5859 }
5860 Ret = IntDestroyMenuObject(Menu, TRUE);
5861
5862Exit:
5863 UserLeave();
5864 TRACE("Leave NtUserDestroyMenu, ret=%i\n", Ret);
5865 return Ret;
5866}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
static void Exit(void)
Definition: sock.c:1330
struct _DESKTOP * rpdesk
Definition: win32.h:92

Referenced by DestroyMenu(), and WIN_CreateWindowEx().

◆ NtUserDrawMenuBarTemp()

DWORD APIENTRY NtUserDrawMenuBarTemp ( HWND  hWnd,
HDC  hDC,
PRECT  pRect,
HMENU  hMenu,
HFONT  hFont 
)

Definition at line 6248 of file menu.c.

6254{
6255 PMENU Menu;
6256 PWND Window;
6257 RECT Rect;
6259 DWORD Ret = 0;
6260
6261 ERR("Enter NtUserDrawMenuBarTemp\n");
6263
6265 {
6267 goto Exit; // Return 0
6268 }
6269
6270 if(!(Menu = UserGetMenuObject(hMenu)))
6271 {
6273 goto Exit; // Return 0
6274 }
6275
6276 _SEH2_TRY
6277 {
6278 ProbeForRead(pRect, sizeof(RECT), sizeof(ULONG));
6279 RtlCopyMemory(&Rect, pRect, sizeof(RECT));
6280 }
6282 {
6284 }
6285 _SEH2_END;
6286
6287 if (Status != STATUS_SUCCESS)
6288 {
6290 goto Exit; // Return 0
6291 }
6292
6293 Ret = IntDrawMenuBarTemp(Window, hDC, &Rect, Menu, hFont);
6294
6295Exit:
6296 UserLeave();
6297 ERR("Leave NtUserDrawMenuBarTemp, ret=%lu\n", Ret);
6298 return Ret;
6299}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59

◆ NtUserEnableMenuItem()

UINT APIENTRY NtUserEnableMenuItem ( HMENU  hMenu,
UINT  uIDEnableItem,
UINT  uEnable 
)

Definition at line 5872 of file menu.c.

5876{
5877 PMENU Menu;
5878 UINT Ret = (UINT)-1;
5879
5880 TRACE("Enter NtUserEnableMenuItem\n");
5882
5883 Menu = UserGetMenuObject(hMenu);
5884 if (Menu)
5885 {
5886 Ret = IntEnableMenuItem(Menu, uIDEnableItem, uEnable);
5887 }
5888
5889 UserLeave();
5890 TRACE("Leave NtUserEnableMenuItem, ret=%u\n", Ret);
5891 return Ret;
5892}

Referenced by EnableMenuItem().

◆ NtUserEndMenu()

BOOL APIENTRY NtUserEndMenu ( VOID  )

Definition at line 5898 of file menu.c.

5899{
5900 //PWND pWnd;
5901 TRACE("Enter NtUserEndMenu\n");
5903 /* if ( gptiCurrent->pMenuState &&
5904 gptiCurrent->pMenuState->pGlobalPopupMenu )
5905 {
5906 pWnd = IntGetMSWND(gptiCurrent->pMenuState);
5907 if (pWnd)
5908 {
5909 UserPostMessage( UserHMGetHandle(pWnd), WM_CANCELMODE, 0, 0);
5910 }
5911 else
5912 gptiCurrent->pMenuState->fInsideMenuLoop = FALSE;
5913 }*/
5915 {
5918 }
5919 UserLeave();
5920 TRACE("Leave NtUserEndMenu\n");
5921 return TRUE;
5922}

◆ NtUserGetMenuBarInfo()

BOOL APIENTRY NtUserGetMenuBarInfo ( HWND  hwnd,
LONG  idObject,
LONG  idItem,
PMENUBARINFO  pmbi 
)

Definition at line 5928 of file menu.c.

5933{
5934 PWND pWnd;
5935 HMENU hMenu;
5936 MENUBARINFO kmbi;
5937 BOOL Ret = FALSE;
5938 PPOPUPMENU pPopupMenu;
5941 PMENU Menu = NULL;
5942
5943 TRACE("Enter NtUserGetMenuBarInfo\n");
5945
5946 if (!(pWnd = UserGetWindowObject(hwnd)))
5947 {
5949 goto Cleanup; // Return FALSE
5950 }
5951
5952 UserRefObjectCo(pWnd, &Ref);
5953
5955 kmbi.hMenu = NULL;
5956 kmbi.hwndMenu = NULL;
5957 kmbi.fBarFocused = FALSE;
5958 kmbi.fFocused = FALSE;
5959
5960 switch (idObject)
5961 {
5962 case OBJID_CLIENT:
5963 if (!pWnd->pcls->fnid)
5964 goto Cleanup; // Return FALSE
5965 if (pWnd->pcls->fnid != FNID_MENU)
5966 {
5967 WARN("called on invalid window: %u\n", pWnd->pcls->fnid);
5969 goto Cleanup; // Return FALSE
5970 }
5971 // Windows does this! Wine checks for Atom and uses GetWindowLongPtrW.
5972 hMenu = (HMENU)co_IntSendMessage(hwnd, MN_GETHMENU, 0, 0);
5973 pPopupMenu = ((PMENUWND)pWnd)->ppopupmenu;
5974 if (pPopupMenu && pPopupMenu->spmenu)
5975 {
5976 if (UserHMGetHandle(pPopupMenu->spmenu) != hMenu)
5977 {
5978 ERR("Window Pop Up hMenu %p not the same as Get hMenu %p!\n", UserHMGetHandle(pPopupMenu->spmenu), hMenu);
5979 }
5980 }
5981 break;
5982 case OBJID_MENU:
5983 if (pWnd->style & WS_CHILD)
5984 goto Cleanup; // Return FALSE
5985 hMenu = UlongToHandle(pWnd->IDMenu);
5986 TRACE("GMBI: OBJID_MENU hMenu %p\n",hMenu);
5987 break;
5988 case OBJID_SYSMENU:
5989 if (!(pWnd->style & WS_SYSMENU))
5990 goto Cleanup; // Return FALSE
5991 Menu = IntGetSystemMenu(pWnd, FALSE);
5992 hMenu = UserHMGetHandle(Menu);
5993 break;
5994 default:
5995 goto Cleanup; // Return FALSE
5996 }
5997
5998 if (!hMenu)
5999 goto Cleanup; // Return FALSE
6000
6001 _SEH2_TRY
6002 {
6003 ProbeForRead(pmbi, sizeof(MENUBARINFO), 1);
6004 kmbi.cbSize = pmbi->cbSize;
6005 }
6007 {
6008 kmbi.cbSize = 0;
6009 }
6010 _SEH2_END
6011
6012 if (kmbi.cbSize != sizeof(MENUBARINFO))
6013 {
6015 goto Cleanup; // Return FALSE
6016 }
6017
6018 if (!Menu)
6019 {
6020 Menu = UserGetMenuObject(hMenu);
6021 if (!Menu)
6022 goto Cleanup; // Return FALSE
6023 }
6024
6025 if ((idItem < 0) || ((ULONG)idItem > Menu->cItems))
6026 goto Cleanup; // Return FALSE
6027
6028 if (idItem == 0)
6029 {
6030 Ret = IntGetMenuItemRect(pWnd, Menu, 0, &kmbi.rcBar);
6031 kmbi.rcBar.right = kmbi.rcBar.left + Menu->cxMenu;
6032 kmbi.rcBar.bottom = kmbi.rcBar.top + Menu->cyMenu;
6033 TRACE("idItem a 0 %d\n",Ret);
6034 }
6035 else
6036 {
6037 Ret = IntGetMenuItemRect(pWnd, Menu, idItem-1, &kmbi.rcBar);
6038 TRACE("idItem b %d %d\n", idItem-1, Ret);
6039 }
6040
6041 kmbi.hMenu = hMenu;
6042 kmbi.fBarFocused = top_popup_hmenu == hMenu;
6043 TRACE("GMBI: top p hm %p hMenu %p\n",top_popup_hmenu, hMenu);
6044 if (idItem)
6045 {
6046 kmbi.fFocused = Menu->iItem == idItem-1;
6047 if (kmbi.fFocused && (Menu->rgItems[idItem - 1].spSubMenu))
6048 {
6049 kmbi.hwndMenu = Menu->rgItems[idItem - 1].spSubMenu->hWnd;
6050 }
6051 }
6052 else
6053 {
6054 kmbi.fFocused = kmbi.fBarFocused;
6055 }
6056
6057 _SEH2_TRY
6058 {
6059 ProbeForWrite(pmbi, sizeof(MENUBARINFO), 1);
6060 RtlCopyMemory(pmbi, &kmbi, sizeof(MENUBARINFO));
6061 }
6063 {
6065 }
6066 _SEH2_END
6067
6068 if (!NT_SUCCESS(Status))
6069 {
6071 Ret = FALSE;
6072 goto Cleanup;
6073 }
6074
6075 Ret = TRUE;
6076
6077Cleanup:
6078 if (pWnd) UserDerefObjectCo(pWnd);
6079 UserLeave();
6080 TRACE("Leave NtUserGetMenuBarInfo, ret=%i\n", Ret);
6081 return Ret;
6082}
static const WCHAR Cleanup[]
Definition: register.c:80
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define FNID_MENU
Definition: ntuser.h:861
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
DWORD fnid
Definition: ntuser.h:570
BOOL fBarFocused
Definition: winuser.h:3806
DWORD cbSize
Definition: winuser.h:3802
PMENU spmenu
Definition: ntuser.h:473
FORCEINLINE VOID RECTL_vSetEmptyRect(_Out_ RECTL *prcl)
Definition: rect.h:20
BOOL FASTCALL IntGetMenuItemRect(PWND pWnd, PMENU Menu, UINT uItem, PRECTL Rect)
Definition: menu.c:5256
#define MN_GETHMENU
Definition: winuser.h:1792

◆ NtUserGetMenuIndex()

UINT APIENTRY NtUserGetMenuIndex ( HMENU  hMenu,
HMENU  hSubMenu 
)

Definition at line 6088 of file menu.c.

6091{
6092 PMENU Menu, SubMenu;
6093 PITEM MenuItem;
6094 UINT i;
6095 UINT Ret = 0xFFFFFFFF;
6096
6097 TRACE("Enter NtUserGetMenuIndex\n");
6099
6100 if ( !(Menu = UserGetMenuObject(hMenu)) ||
6101 !(SubMenu = UserGetMenuObject(hSubMenu)) )
6102 goto Exit; // Return 0xFFFFFFFF
6103
6104 MenuItem = Menu->rgItems;
6105 for (i = 0; i < Menu->cItems; i++, MenuItem++)
6106 {
6107 if (MenuItem->spSubMenu == SubMenu)
6108 {
6109 Ret = MenuItem->wID;
6110 break;
6111 }
6112 }
6113
6114Exit:
6115 UserLeave();
6116 TRACE("Leave NtUserGetMenuIndex, ret=%u\n", Ret);
6117 return Ret;
6118}

Referenced by GetMenuIndex().

◆ NtUserGetMenuItemRect()

BOOL APIENTRY NtUserGetMenuItemRect ( HWND  hWnd,
HMENU  hMenu,
UINT  uItem,
PRECTL  lprcItem 
)

Definition at line 6124 of file menu.c.

6129{
6130 PWND ReferenceWnd;
6131 LONG XMove, YMove;
6132 RECTL Rect;
6133 PMENU Menu;
6134 PITEM MenuItem;
6136 BOOL Ret = FALSE;
6137
6138 TRACE("Enter NtUserGetMenuItemRect\n");
6140
6141 if (!(Menu = UserGetMenuObject(hMenu)))
6142 {
6143 goto Exit; // Return FALSE
6144 }
6145
6146 if ((MenuItem = MENU_FindItem (&Menu, &uItem, MF_BYPOSITION)))
6147 {
6148 Rect.left = MenuItem->xItem;
6149 Rect.top = MenuItem->yItem;
6150 Rect.right = MenuItem->cxItem; // Do this for now......
6151 Rect.bottom = MenuItem->cyItem;
6152 }
6153 else
6154 goto Exit; // Return FALSE
6155
6156 if(!hWnd)
6157 {
6158 hWnd = Menu->hWnd;
6159 }
6160
6161 if (lprcItem == NULL)
6162 goto Exit; // Return FALSE
6163
6164 if (!(ReferenceWnd = UserGetWindowObject(hWnd)))
6165 goto Exit; // Return FALSE
6166
6167 if (Menu->fFlags & MNF_POPUP)
6168 {
6169 XMove = ReferenceWnd->rcClient.left;
6170 YMove = ReferenceWnd->rcClient.top;
6171 }
6172 else
6173 {
6174 XMove = ReferenceWnd->rcWindow.left;
6175 YMove = ReferenceWnd->rcWindow.top;
6176 }
6177
6178 Rect.left += XMove;
6179 Rect.top += YMove;
6180 Rect.right += XMove;
6181 Rect.bottom += YMove;
6182
6183 _SEH2_TRY
6184 {
6185 RtlCopyMemory(lprcItem, &Rect, sizeof(RECTL));
6186 }
6188 {
6190 }
6191 _SEH2_END
6192
6193 if (!NT_SUCCESS(Status))
6194 {
6196 goto Exit; // Return FALSE
6197 }
6198 Ret = TRUE;
6199
6200Exit:
6201 UserLeave();
6202 TRACE("Leave NtUserGetMenuItemRect, ret=%i\n", Ret);
6203 return Ret;
6204}

◆ NtUserGetSystemMenu()

HMENU APIENTRY NtUserGetSystemMenu ( HWND  hWnd,
BOOL  bRevert 
)

Definition at line 5685 of file menu.c.

5686{
5687 PWND Window;
5688 PMENU Menu;
5689 HMENU Ret = NULL;
5690
5691 TRACE("Enter NtUserGetSystemMenu\n");
5693
5695 {
5696 goto Exit; // Return NULL
5697 }
5698
5699 if (!(Menu = IntGetSystemMenu(Window, bRevert)))
5700 {
5701 goto Exit; // Return NULL
5702 }
5703
5704 Ret = UserHMGetHandle(Menu);
5705
5706Exit:
5707 UserLeave();
5708 TRACE("Leave NtUserGetSystemMenu, ret=%p\n", Ret);
5709 return Ret;
5710}

Referenced by GetSystemMenu().

◆ NtUserGetTitleBarInfo()

BOOLEAN APIENTRY NtUserGetTitleBarInfo ( HWND  hwnd,
PTITLEBARINFO  bti 
)

Definition at line 5759 of file menu.c.

5762{
5763 PWND WindowObject;
5764 TITLEBARINFO bartitleinfo;
5765 BOOLEAN retValue = FALSE;
5766
5767 TRACE("Enter NtUserGetTitleBarInfo\n");
5769
5770 /* Validate the window handle */
5771 if (!(WindowObject = UserGetWindowObject(hwnd)))
5772 {
5774 goto Exit;
5775 }
5776
5777 /* Copy user mode buffer to local buffer */
5778 _SEH2_TRY
5779 {
5780 ProbeForRead(bti, sizeof(TITLEBARINFO), 1);
5781 RtlCopyMemory(&bartitleinfo, bti, sizeof(TITLEBARINFO));
5782 }
5784 {
5786 _SEH2_YIELD(goto Exit);
5787 }
5788 _SEH2_END
5789
5790 /* Get the tile bar info */
5791 retValue = intGetTitleBarInfo(WindowObject, &bartitleinfo);
5792 if (!retValue)
5793 {
5794 // intGetTitleBarInfo() set LastError.
5795 goto Exit;
5796 }
5797
5798 /* Copy local buffer back to user mode buffer */
5799 _SEH2_TRY
5800 {
5801 ProbeForWrite(bti, sizeof(TITLEBARINFO), 1);
5802 RtlCopyMemory(bti, &bartitleinfo, sizeof(TITLEBARINFO));
5803 }
5805 {
5807 retValue = FALSE;
5808 }
5809 _SEH2_END;
5810
5811Exit:
5812 UserLeave();
5813 TRACE("Leave NtUserGetTitleBarInfo, ret=%u\n", retValue);
5814 return retValue;
5815}
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
BOOLEAN APIENTRY intGetTitleBarInfo(PWND pWindowObject, PTITLEBARINFO bti)
Definition: menu.c:4830

Referenced by GetTitleBarInfo(), and START_TEST().

◆ NtUserHiliteMenuItem()

BOOL APIENTRY NtUserHiliteMenuItem ( HWND  hWnd,
HMENU  hMenu,
UINT  uItemHilite,
UINT  uHilite 
)

Definition at line 6210 of file menu.c.

6215{
6216 PMENU Menu;
6217 PWND Window;
6218 BOOL Ret = FALSE;
6219
6220 TRACE("Enter NtUserHiliteMenuItem\n");
6222
6224 {
6226 goto Exit; // Return FALSE
6227 }
6228
6229 if(!(Menu = UserGetMenuObject(hMenu)))
6230 {
6232 goto Exit; // Return FALSE
6233 }
6234
6235 Ret = IntHiliteMenuItem(Window, Menu, uItemHilite, uHilite);
6236
6237Exit:
6238 UserLeave();
6239 TRACE("Leave NtUserHiliteMenuItem, ret=%i\n", Ret);
6240 return Ret;
6241}
BOOL FASTCALL IntHiliteMenuItem(PWND WindowObject, PMENU MenuObject, UINT uItemHilite, UINT uHilite)
Definition: menu.c:4804

◆ NtUserMenuItemFromPoint()

int APIENTRY NtUserMenuItemFromPoint ( HWND  hWnd,
HMENU  hMenu,
DWORD  X,
DWORD  Y 
)

Definition at line 6305 of file menu.c.

6310{
6311 PMENU Menu;
6312 PWND Window = NULL;
6313 PITEM mi;
6314 ULONG i;
6315 int Ret = -1;
6316
6317 TRACE("Enter NtUserMenuItemFromPoint\n");
6319
6320 if (!(Menu = UserGetMenuObject(hMenu)))
6321 {
6322 goto Exit; // Return -1
6323 }
6324
6325 if (!(Window = UserGetWindowObject(Menu->hWnd)))
6326 {
6327 goto Exit; // Return -1
6328 }
6329
6330 X -= Window->rcWindow.left;
6331 Y -= Window->rcWindow.top;
6332
6333 mi = Menu->rgItems;
6334 for (i = 0; i < Menu->cItems; i++, mi++)
6335 {
6336 RECTL Rect;
6337
6338 Rect.left = mi->xItem;
6339 Rect.top = mi->yItem;
6340 Rect.right = mi->cxItem;
6341 Rect.bottom = mi->cyItem;
6342
6344
6345 if (RECTL_bPointInRect(&Rect, X, Y))
6346 {
6347 break;
6348 }
6349 }
6350
6351 Ret = (mi ? i : NO_SELECTED_ITEM);
6352
6353Exit:
6354 UserLeave();
6355 TRACE("Leave NtUserMenuItemFromPoint, ret=%i\n", Ret);
6356 return Ret;
6357}
#define Y(I)
static MONITORINFO mi
Definition: win.c:7338

◆ NtUserPaintMenuBar()

DWORD APIENTRY NtUserPaintMenuBar ( HWND  hWnd,
HDC  hDC,
ULONG  leftBorder,
ULONG  rightBorder,
ULONG  top,
BOOL  bActive 
)

Definition at line 6362 of file menu.c.

6369{
6370 PWND Window;
6371 RECT Rect;
6372 DWORD ret;
6373
6375
6377 {
6378 UserLeave();
6380 return 0;
6381 }
6382
6383 Rect.left = leftBorder;
6384 Rect.right = Window->rcWindow.right - Window->rcWindow.left - rightBorder;
6385 Rect.top = top;
6386 Rect.bottom = 0;
6387
6389
6390 UserLeave();
6391 return ret;
6392}

◆ NtUserRemoveMenu()

BOOL APIENTRY NtUserRemoveMenu ( HMENU  hMenu,
UINT  uPosition,
UINT  uFlags 
)

Definition at line 6398 of file menu.c.

6402{
6403 PMENU Menu;
6404 BOOL Ret = FALSE;
6405
6406 TRACE("Enter NtUserRemoveMenu\n");
6408
6409 Menu = UserGetMenuObject(hMenu);
6410 if (Menu)
6411 {
6412 Ret = IntRemoveMenuItem(Menu, uPosition, uFlags, FALSE);
6413 }
6414
6415 UserLeave();
6416 TRACE("Leave NtUserRemoveMenu, ret=%i\n", Ret);
6417 return Ret;
6418}

Referenced by RemoveMenu().

◆ NtUserSetMenu()

BOOL APIENTRY NtUserSetMenu ( HWND  hWnd,
HMENU  Menu,
BOOL  Repaint 
)

Definition at line 6424 of file menu.c.

6428{
6429 PWND Window;
6430 BOOL Changed;
6431 BOOL Ret = FALSE;
6432
6433 TRACE("Enter NtUserSetMenu\n");
6435
6437 {
6438 goto Exit; // Return FALSE
6439 }
6440
6441 if (!IntSetMenu(Window, Menu, &Changed))
6442 {
6443 goto Exit; // Return FALSE
6444 }
6445
6446 // Not minimized and please repaint!!!
6447 if (!(Window->style & WS_MINIMIZE) && (Repaint || Changed))
6448 {
6450 UserRefObjectCo(Window, &Ref);
6453 }
6454
6455 Ret = TRUE;
6456
6457Exit:
6458 UserLeave();
6459 TRACE("Leave NtUserSetMenu, ret=%i\n", Ret);
6460 return Ret;
6461}
BOOL FASTCALL IntSetMenu(PWND Wnd, HMENU Menu, BOOL *Changed)
Definition: menu.c:5485
#define SWP_FRAMECHANGED
Definition: winuser.h:1251
#define SWP_NOMOVE
Definition: winuser.h:1255
#define SWP_NOSIZE
Definition: winuser.h:1256
#define SWP_NOZORDER
Definition: winuser.h:1258

Referenced by SetMenu().

◆ NtUserSetMenuContextHelpId()

BOOL APIENTRY NtUserSetMenuContextHelpId ( HMENU  hMenu,
DWORD  dwContextHelpId 
)

Definition at line 6467 of file menu.c.

6470{
6471 PMENU Menu;
6472 BOOL Ret = FALSE;
6473
6474 TRACE("Enter NtUserSetMenuContextHelpId\n");
6476
6477 Menu = UserGetMenuObject(hMenu);
6478 if (Menu)
6479 {
6480 Ret = IntSetMenuContextHelpId(Menu, dwContextHelpId);
6481 }
6482
6483 UserLeave();
6484 TRACE("Leave NtUserSetMenuContextHelpId, ret=%i\n", Ret);
6485 return Ret;
6486}
BOOL FASTCALL IntSetMenuContextHelpId(PMENU Menu, DWORD dwContextHelpId)
Definition: menu.c:872

Referenced by SetMenuContextHelpId().

◆ NtUserSetMenuDefaultItem()

BOOL APIENTRY NtUserSetMenuDefaultItem ( HMENU  hMenu,
UINT  uItem,
UINT  fByPos 
)

Definition at line 6492 of file menu.c.

6496{
6497 PMENU Menu;
6498 BOOL Ret = FALSE;
6499
6500 TRACE("Enter NtUserSetMenuDefaultItem\n");
6502
6503 Menu = UserGetMenuObject(hMenu);
6504 if (Menu)
6505 {
6506 Ret = UserSetMenuDefaultItem(Menu, uItem, fByPos);
6507 }
6508
6509 UserLeave();
6510 TRACE("Leave NtUserSetMenuDefaultItem, ret=%i\n", Ret);
6511 return Ret;
6512}

Referenced by SetMenuDefaultItem().

◆ NtUserSetMenuFlagRtoL()

BOOL APIENTRY NtUserSetMenuFlagRtoL ( HMENU  hMenu)

Definition at line 6518 of file menu.c.

6520{
6521 PMENU Menu;
6522 BOOL Ret = FALSE;
6523
6524 TRACE("Enter NtUserSetMenuFlagRtoL\n");
6526
6527 Menu = UserGetMenuObject(hMenu);
6528 if (Menu)
6529 {
6530 Ret = IntSetMenuFlagRtoL(Menu);
6531 }
6532
6533 UserLeave();
6534 TRACE("Leave NtUserSetMenuFlagRtoL, ret=%i\n", Ret);
6535 return Ret;
6536}
BOOL FASTCALL IntSetMenuFlagRtoL(PMENU Menu)
Definition: menu.c:864

◆ NtUserSetSystemMenu()

BOOL APIENTRY NtUserSetSystemMenu ( HWND  hWnd,
HMENU  hMenu 
)

Definition at line 5720 of file menu.c.

5721{
5722 BOOL Result = FALSE;
5723 PWND Window;
5724 PMENU Menu;
5725
5726 TRACE("Enter NtUserSetSystemMenu\n");
5728
5730 {
5731 goto Exit; // Return FALSE
5732 }
5733
5734 if (hMenu)
5735 {
5736 /*
5737 * Assign new menu handle and Up the Lock Count.
5738 */
5739 if (!(Menu = IntGetMenuObject(hMenu)))
5740 {
5741 goto Exit; // Return FALSE
5742 }
5743
5745 }
5746 else
5748
5749Exit:
5750 UserLeave();
5751 TRACE("Leave NtUserSetSystemMenu, ret=%i\n", Result);
5752 return Result;
5753}
BOOL FASTCALL IntSetSystemMenu(PWND Window, PMENU Menu)
Definition: menu.c:5452
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by SetSystemMenu().

◆ NtUserThunkedMenuInfo()

BOOL APIENTRY NtUserThunkedMenuInfo ( HMENU  hMenu,
LPCMENUINFO  lpcmi 
)

Definition at line 6542 of file menu.c.

6545{
6546 PMENU Menu;
6547 BOOL Ret = FALSE;
6548
6549 TRACE("Enter NtUserThunkedMenuInfo\n");
6551
6552 Menu = UserGetMenuObject(hMenu);
6553 if (Menu)
6554 {
6555 Ret = UserMenuInfo(Menu, (PROSMENUINFO)lpcmi, TRUE);
6556 }
6557
6558 UserLeave();
6559 TRACE("Leave NtUserThunkedMenuInfo, ret=%i\n", Ret);
6560 return Ret;
6561}
BOOL FASTCALL UserMenuInfo(PMENU Menu, PROSMENUINFO UnsafeMenuInfo, BOOL SetOrGet)
Definition: menu.c:5204

Referenced by SetMenuInfo().

◆ NtUserThunkedMenuItemInfo()

BOOL APIENTRY NtUserThunkedMenuItemInfo ( HMENU  hMenu,
UINT  uItem,
BOOL  fByPosition,
BOOL  bInsert,
LPMENUITEMINFOW  lpmii,
PUNICODE_STRING  lpszCaption 
)

Definition at line 6567 of file menu.c.

6574{
6575 PMENU Menu;
6577 UNICODE_STRING lstrCaption = { 0 };
6578 BOOL Ret = FALSE;
6579
6580 TRACE("Enter NtUserThunkedMenuItemInfo\n");
6581
6583
6584 if (!(Menu = UserGetMenuObject(hMenu)))
6585 {
6586 goto Cleanup; // Return FALSE
6587 }
6588
6589 /* Check if we got a Caption */
6590 if (lpszCaption && lpszCaption->Buffer)
6591 {
6592 /* Copy the string to kernel mode */
6593 Status = ProbeAndCaptureUnicodeString( &lstrCaption,
6594 UserMode,
6595 lpszCaption);
6596 if (!NT_SUCCESS(Status))
6597 {
6598 ERR("Failed to capture MenuItem Caption (status 0x%08x)\n",Status);
6600 goto Cleanup; // Return FALSE
6601 }
6602 }
6603
6604 if (bInsert)
6605 {
6606 Ret = UserInsertMenuItem(Menu, uItem, fByPosition, lpmii, &lstrCaption);
6607 }
6608 else
6609 {
6610 Ret = UserMenuItemInfo(Menu, uItem, fByPosition, (PROSMENUITEMINFO)lpmii, TRUE, &lstrCaption);
6611 }
6612
6613Cleanup:
6614 UserLeave();
6615
6616 if (lstrCaption.Buffer)
6617 {
6619 }
6620
6621 TRACE("Leave NtUserThunkedMenuItemInfo, ret=%i\n", Ret);
6622 return Ret;
6623}
static BOOL bInsert
Definition: cmdinput.c:121
#define UserMode
Definition: asm.h:39
static __inline NTSTATUS ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, IN KPROCESSOR_MODE CurrentMode, IN const UNICODE_STRING *UnsafeSrc)
Definition: probe.h:142
static __inline VOID ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, IN KPROCESSOR_MODE CurrentMode)
Definition: probe.h:239
DWORD FASTCALL UserInsertMenuItem(PMENU Menu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW UnsafeItemInfo, PUNICODE_STRING lpstr)
Definition: menu.c:4961
BOOL FASTCALL UserMenuItemInfo(PMENU Menu, UINT Item, BOOL ByPosition, PROSMENUITEMINFO UnsafeItemInfo, BOOL SetOrGet, PUNICODE_STRING lpstr)
Definition: menu.c:5130

Referenced by AppendMenuA(), AppendMenuW(), CheckMenuRadioItem(), InsertMenuA(), InsertMenuItemA(), InsertMenuItemW(), InsertMenuW(), ModifyMenuA(), ModifyMenuW(), SetMenuItemInfoA(), and SetMenuItemInfoW().

◆ NtUserTrackPopupMenuEx()

BOOL NTAPI NtUserTrackPopupMenuEx ( _In_ HMENU  hMenu,
_In_ UINT  fuFlags,
_In_ INT  x,
_In_ INT  y,
_In_ HWND  hWnd,
_In_opt_ LPTPMPARAMS  lptpm 
)

Definition at line 6634 of file menu.c.

6641{
6642 PMENU menu;
6643 PWND pWnd;
6644 TPMPARAMS tpm;
6645 BOOL Ret = FALSE;
6646 USER_REFERENCE_ENTRY WndRef, MenuRef;
6647
6648 TRACE("Enter NtUserTrackPopupMenuEx\n");
6649
6650 if (fuFlags & ~VALID_TPM_FLAGS)
6651 {
6652 ERR("TPME : Invalid flags 0x%X (valid flags are 0x%X)\n", fuFlags, VALID_TPM_FLAGS);
6654 goto Exit0;
6655 }
6656
6658
6659 /* Parameter check */
6660 if (!(menu = UserGetMenuObject( hMenu )))
6661 {
6662 ERR("TPME : Invalid Menu handle.\n");
6664 goto Exit;
6665 }
6666
6667 if (!(pWnd = UserGetWindowObject(hWnd)))
6668 {
6669 ERR("TPME : Invalid Window handle.\n");
6670 goto Exit;
6671 }
6672
6673 if (lptpm)
6674 {
6675 _SEH2_TRY
6676 {
6677 ProbeForRead(lptpm, sizeof(TPMPARAMS), sizeof(ULONG));
6678 tpm = *lptpm;
6679 }
6681 {
6682 _SEH2_YIELD(goto Exit);
6683 }
6684 _SEH2_END
6685 }
6686
6687 UserRefObjectCo(pWnd, &WndRef);
6688 UserRefObjectCo(menu, &MenuRef);
6689 Ret = IntTrackPopupMenuEx(menu, fuFlags, x, y, pWnd, (lptpm ? &tpm : NULL));
6690 UserDerefObjectCo(menu);
6691 UserDerefObjectCo(pWnd);
6692
6693Exit:
6694 UserLeave();
6695
6696Exit0:
6697 TRACE("Leave NtUserTrackPopupMenuEx, ret=%i\n", Ret);
6698 return Ret;
6699}
BOOL FASTCALL IntTrackPopupMenuEx(_Inout_ PMENU menu, _In_ UINT wFlags, _In_ INT x, _In_ INT y, _In_ PWND pWnd, _In_opt_ const TPMPARAMS *lpTpm)
Definition: menu.c:4575
#define VALID_TPM_FLAGS
Definition: menu.c:6625
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583

Referenced by TrackPopupMenu().

◆ PopupMenuWndProc()

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

Definition at line 4657 of file menu.c.

4663{
4664 PPOPUPMENU pPopupMenu;
4665
4666 *lResult = 0;
4667
4668 TRACE("PMWP : pwnd=%x msg=%d wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
4669
4670 if (Wnd)
4671 {
4672 if (!Wnd->fnid)
4673 {
4674 if (Message != WM_NCCREATE)
4675 {
4676 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4677 return TRUE;
4678 }
4679 Wnd->fnid = FNID_MENU;
4680 pPopupMenu = DesktopHeapAlloc( Wnd->head.rpdesk, sizeof(POPUPMENU) );
4681 if (pPopupMenu == NULL)
4682 {
4683 return TRUE;
4684 }
4685 pPopupMenu->posSelectedItem = NO_SELECTED_ITEM;
4686 pPopupMenu->spwndPopupMenu = Wnd;
4687 ((PMENUWND)Wnd)->ppopupmenu = pPopupMenu;
4688 TRACE("Pop Up Menu is Setup! Msg %d\n",Message);
4689 *lResult = 1;
4690 return TRUE;
4691 }
4692 else
4693 {
4694 if (Wnd->fnid != FNID_MENU)
4695 {
4696 ERR("Wrong window class for Menu! fnid %x\n",Wnd->fnid);
4697 return TRUE;
4698 }
4699 pPopupMenu = ((PMENUWND)Wnd)->ppopupmenu;
4700 }
4701 }
4702
4703 switch(Message)
4704 {
4705 case WM_CREATE:
4706 {
4708 pPopupMenu->spmenu = UserGetMenuObject(cs->lpCreateParams);
4709 if (pPopupMenu->spmenu)
4710 {
4711 UserReferenceObject(pPopupMenu->spmenu);
4712 }
4713 break;
4714 }
4715
4716 case WM_MOUSEACTIVATE: /* We don't want to be activated */
4717 *lResult = MA_NOACTIVATE;
4718 break;
4719
4720 case WM_PAINT:
4721 {
4722 PAINTSTRUCT ps;
4723 IntBeginPaint(Wnd, &ps);
4724 MENU_DrawPopupMenu(Wnd, ps.hdc, pPopupMenu->spmenu);
4725 IntEndPaint(Wnd, &ps);
4726 break;
4727 }
4728
4729 case WM_PRINTCLIENT:
4730 {
4731 MENU_DrawPopupMenu( Wnd, (HDC)wParam, pPopupMenu->spmenu);
4732 break;
4733 }
4734
4735 case WM_ERASEBKGND:
4736 *lResult = 1;
4737 break;
4738
4739 case WM_DESTROY:
4740 /* zero out global pointer in case resident popup window was destroyed. */
4741 if (pPopupMenu)
4742 {
4743 if (UserHMGetHandle(Wnd) == top_popup)
4744 {
4745 top_popup = NULL;
4747 }
4748 }
4749 else
4750 {
4751 ERR("No Window Pop Up!\n");
4752 }
4753 break;
4754
4755 case WM_NCDESTROY:
4756 {
4757 if (pPopupMenu->spmenu)
4758 {
4759 IntReleaseMenuObject(pPopupMenu->spmenu);
4760 }
4761 DesktopHeapFree(Wnd->head.rpdesk, pPopupMenu );
4762 ((PMENUWND)Wnd)->ppopupmenu = 0;
4763 Wnd->fnid = FNID_DESTROY;
4764 break;
4765 }
4766
4767 case MM_SETMENUHANDLE: // wine'isms
4768 case MN_SETHMENU:
4769 {
4771 if (!pmenu)
4772 {
4773 ERR("Bad Menu Handle\n");
4774 break;
4775 }
4776 UserReferenceObject(pmenu);
4777 if (pPopupMenu->spmenu)
4778 {
4779 IntReleaseMenuObject(pPopupMenu->spmenu);
4780 }
4781 pPopupMenu->spmenu = pmenu;
4782 break;
4783 }
4784
4785 case MM_GETMENUHANDLE: // wine'isms
4786 case MN_GETHMENU:
4787 *lResult = (LRESULT)(pPopupMenu ? (pPopupMenu->spmenu ? UserHMGetHandle(pPopupMenu->spmenu) : NULL) : NULL);
4788 break;
4789
4790 default:
4791 if (Message > MN_GETHMENU && Message < MN_GETHMENU+19)
4792 {
4793 ERR("Someone is passing unknown menu messages %d\n",Message);
4794 }
4795 TRACE("PMWP to IDWP %d\n",Message);
4796 *lResult = IntDefWindowProc(Wnd, Message, wParam, lParam, FALSE);
4797 break;
4798 }
4799
4800 return TRUE;
4801}
LPARAM lParam
Definition: combotst.c:139
static const WCHAR Message[]
Definition: register.c:74
#define cs
Definition: i386-dis.c:442
#define FNID_DESTROY
Definition: ntuser.h:898
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:638
#define LRESULT
Definition: ole.h:14
#define WM_PRINTCLIENT
Definition: richedit.h:70
struct _DESKTOP * rpdesk
Definition: ntuser.h:194
DWORD fnid
Definition: ntuser.h:709
UINT posSelectedItem
Definition: ntuser.h:478
struct _WND * spwndPopupMenu
Definition: ntuser.h:470
#define MN_SETHMENU
Definition: undocuser.h:55
HDC FASTCALL IntBeginPaint(PWND Window, PPAINTSTRUCT Ps)
Definition: painting.c:1442
BOOL FASTCALL IntEndPaint(PWND Wnd, PPAINTSTRUCT Ps)
Definition: painting.c:1539
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_ERASEBKGND
Definition: winuser.h:1644
#define WM_CREATE
Definition: winuser.h:1627
#define MA_NOACTIVATE
Definition: winuser.h:2522
#define WM_NCCREATE
Definition: winuser.h:1702
#define WM_MOUSEACTIVATE
Definition: winuser.h:1656
#define WM_NCDESTROY
Definition: winuser.h:1703
#define WM_DESTROY
Definition: winuser.h:1628

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

◆ RECTL_Intersect()

static BOOL RECTL_Intersect ( const RECT pRect,
INT  x,
INT  y,
UINT  width,
UINT  height 
)
static

Definition at line 2880 of file menu.c.

2881{
2882 RECT other = {x, y, x + width, y + height};
2883 RECT dum;
2884
2885 return RECTL_bIntersectRect(&dum, pRect, &other);
2886}
CDumExe dum
Definition: CComObject.cpp:71
int other
Definition: msacm.c:1376

Referenced by MENU_ShowPopup().

◆ UITOOLS95_DrawFrameMenu()

BOOL FASTCALL UITOOLS95_DrawFrameMenu ( HDC  dc,
LPRECT  r,
UINT  uFlags 
)

Definition at line 959 of file draw.c.

960{
961 LOGFONTW lf;
962 HFONT hFont, hOldFont;
964 RECT myr;
965 INT cxy;
966 cxy = UITOOLS_MakeSquareRect(r, &myr);
967 switch(uFlags & 0x1f)
968 {
969 case DFCS_MENUARROWUP:
970 Symbol = '5';
971 break;
972
974 Symbol = '6';
975 break;
976
977 case DFCS_MENUARROW:
978 Symbol = '8';
979 break;
980
982 Symbol = 'w'; // FIXME: needs to confirm
983 break;
984
985 case DFCS_MENUBULLET:
986 Symbol = 'h';
987 break;
988
989 case DFCS_MENUCHECK:
991 Symbol = 'a';
992 break;
993
994 default:
995 ERR("Invalid menu; flags=0x%04x\n", uFlags);
996 return FALSE;
997 }
998 /* acquire ressources only if valid menu */
999 RtlZeroMemory(&lf, sizeof(LOGFONTW));
1000 lf.lfHeight = cxy;
1001 lf.lfWidth = 0;
1002 lf.lfWeight = FW_NORMAL;
1004 RtlCopyMemory(lf.lfFaceName, L"Marlett", sizeof(L"Marlett"));
1006 /* save font */
1007 hOldFont = NtGdiSelectFont(dc, hFont);
1008
1009 if ((uFlags & 0x1f) == DFCS_MENUARROWUP ||
1010 (uFlags & 0x1f) == DFCS_MENUARROWDOWN )
1011 {
1012#if 0
1013 if (uFlags & DFCS_INACTIVE)
1014 {
1015 /* draw shadow */
1017 GreTextOutW(dc, myr.left + 1, myr.top + 1, &Symbol, 1);
1018 }
1019#endif
1021 }
1022 /* draw selected symbol */
1023 GreTextOutW(dc, myr.left, myr.top, &Symbol, 1);
1024 /* restore previous settings */
1025 NtGdiSelectFont(dc, hOldFont);
1027 return TRUE;
1028}
Definition: Symbol.h:9
int FASTCALL UITOOLS_MakeSquareRect(LPRECT src, LPRECT dst)
Definition: draw.c:566
#define COLOR_BTNTEXT
Definition: winuser.h:944
#define DFCS_MENUARROWRIGHT
Definition: winuser.h:488

Referenced by DrawFrameControl(), MENU_DrawMenuItem(), MENU_DrawScrollArrows(), and RealDrawFrameControl().

◆ UserCreateMenu()

HMENU FASTCALL UserCreateMenu ( PDESKTOP  Desktop,
BOOL  PopupMenu 
)

Definition at line 5058 of file menu.c.

5059{
5060 PWINSTATION_OBJECT WinStaObject;
5061 HANDLE Handle;
5062 PMENU Menu;
5064 PEPROCESS CurrentProcess = PsGetCurrentProcess();
5065
5066 if (gpepCSRSS != CurrentProcess)
5067 {
5068 /*
5069 * gpepCSRSS does not have a Win32WindowStation
5070 */
5071
5073 UserMode,
5074 0,
5075 &WinStaObject,
5076 0);
5077
5078 if (!NT_SUCCESS(Status))
5079 {
5080 ERR("Validation of window station handle (%p) failed\n",
5081 CurrentProcess->Win32WindowStation);
5083 return (HMENU)0;
5084 }
5085 Menu = IntCreateMenu(&Handle, !PopupMenu, Desktop, GetW32ProcessInfo());
5086 if (Menu && Menu->head.rpdesk->rpwinstaParent != WinStaObject)
5087 {
5088 ERR("Desktop Window Station does not match Process one!\n");
5089 }
5090 ObDereferenceObject(WinStaObject);
5091 }
5092 else
5093 {
5094 Menu = IntCreateMenu(&Handle, !PopupMenu, GetW32ThreadInfo()->rpdesk, GetW32ProcessInfo());
5095 }
5096
5097 if (Menu) UserDereferenceObject(Menu);
5098 return (HMENU)Handle;
5099}
PEPROCESS gpepCSRSS
Definition: csr.c:15
struct _PROCESSINFO * GetW32ProcessInfo(VOID)
Definition: misc.c:801
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:807
NTSTATUS FASTCALL IntValidateWindowStationHandle(HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PWINSTATION_OBJECT *Object, POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
Definition: winsta.c:232
PVOID Win32WindowStation
Definition: pstypes.h:1309
#define ObDereferenceObject
Definition: obfuncs.h:203
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by MENU_GetSystemMenu(), and NtUserCallNoParam().

◆ UserDestroyMenu()

BOOL FASTCALL UserDestroyMenu ( HMENU  hMenu)

Definition at line 5820 of file menu.c.

5821{
5822 PMENU Menu;
5824
5825 if(!(Menu = UserGetMenuObject(hMenu)))
5826 {
5827 return FALSE;
5828 }
5829
5830 if (Menu->head.rpdesk != pti->rpdesk)
5831 {
5833 return FALSE;
5834 }
5835 return IntDestroyMenuObject(Menu, FALSE);
5836}

Referenced by MENU_GetSystemMenu().

◆ UserDestroyMenuObject()

BOOLEAN UserDestroyMenuObject ( PVOID  Object)

Definition at line 311 of file menu.c.

312{
314}
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

◆ UserInsertMenuItem()

DWORD FASTCALL UserInsertMenuItem ( PMENU  Menu,
UINT  uItem,
BOOL  fByPosition,
LPCMENUITEMINFOW  UnsafeItemInfo,
PUNICODE_STRING  lpstr 
)

Definition at line 4961 of file menu.c.

4967{
4969 ROSMENUITEMINFO ItemInfo;
4970
4971 /* Try to copy the whole MENUITEMINFOW structure */
4972 Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
4973 if (NT_SUCCESS(Status))
4974 {
4975 if (sizeof(MENUITEMINFOW) != ItemInfo.cbSize
4976 && FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
4977 {
4979 return FALSE;
4980 }
4981 return IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo, lpstr);
4982 }
4983
4984 /* Try to copy without last field (not present in older versions) */
4985 Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, FIELD_OFFSET(MENUITEMINFOW, hbmpItem));
4986 if (NT_SUCCESS(Status))
4987 {
4988 if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) != ItemInfo.cbSize)
4989 {
4991 return FALSE;
4992 }
4993 ItemInfo.hbmpItem = (HBITMAP)0;
4994 return IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo, lpstr);
4995 }
4996
4998 return FALSE;
4999}
#define MmCopyFromCaller
Definition: polytest.cpp:29
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by NtUserThunkedMenuItemInfo().

◆ UserMenuInfo()

BOOL FASTCALL UserMenuInfo ( PMENU  Menu,
PROSMENUINFO  UnsafeMenuInfo,
BOOL  SetOrGet 
)

Definition at line 5204 of file menu.c.

5208{
5209 BOOL Res;
5210 DWORD Size;
5213
5214 Status = MmCopyFromCaller(&Size, &UnsafeMenuInfo->cbSize, sizeof(DWORD));
5215 if (! NT_SUCCESS(Status))
5216 {
5218 return FALSE;
5219 }
5220 if ( Size < sizeof(MENUINFO) || Size > sizeof(ROSMENUINFO) )
5221 {
5223 return FALSE;
5224 }
5225 Status = MmCopyFromCaller(&MenuInfo, UnsafeMenuInfo, Size);
5226 if (! NT_SUCCESS(Status))
5227 {
5229 return FALSE;
5230 }
5231
5232 if(SetOrGet)
5233 {
5234 /* Set MenuInfo */
5235 Res = IntSetMenuInfo(Menu, &MenuInfo);
5236 }
5237 else
5238 {
5239 /* Get MenuInfo */
5240 Res = IntGetMenuInfo(Menu, &MenuInfo);
5241 if (Res)
5242 {
5243 Status = MmCopyToCaller(UnsafeMenuInfo, &MenuInfo, Size);
5244 if (! NT_SUCCESS(Status))
5245 {
5247 return FALSE;
5248 }
5249 }
5250 }
5251
5252 return Res;
5253}
menu info structure
Definition: window.h:276
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
BOOL FASTCALL IntGetMenuInfo(PMENU Menu, PROSMENUINFO lpmi)
Definition: menu.c:879

Referenced by NtUserThunkedMenuInfo().

◆ UserMenuItemInfo()

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

Definition at line 5130 of file menu.c.

5137{
5138 PITEM MenuItem;
5139 ROSMENUITEMINFO ItemInfo;
5141 UINT Size;
5142 BOOL Ret;
5143
5144 Status = MmCopyFromCaller(&Size, &UnsafeItemInfo->cbSize, sizeof(UINT));
5145 if (! NT_SUCCESS(Status))
5146 {
5148 return FALSE;
5149 }
5150 if ( Size != sizeof(MENUITEMINFOW) &&
5151 Size != FIELD_OFFSET(MENUITEMINFOW, hbmpItem) &&
5152 Size != sizeof(ROSMENUITEMINFO) )
5153 {
5155 return FALSE;
5156 }
5157 Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, Size);
5158 if (! NT_SUCCESS(Status))
5159 {
5161 return FALSE;
5162 }
5163 /* If this is a pre-0x0500 _WIN32_WINNT MENUITEMINFOW, you can't
5164 set/get hbmpItem */
5165 if (FIELD_OFFSET(MENUITEMINFOW, hbmpItem) == Size
5166 && 0 != (ItemInfo.fMask & MIIM_BITMAP))
5167 {
5169 return FALSE;
5170 }
5171
5172 if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5173 {
5174 /* workaround for Word 95: pretend that SC_TASKLIST item exists. */
5175 if ( SetOrGet && Item == SC_TASKLIST && !ByPosition )
5176 return TRUE;
5177
5179 return FALSE;
5180 }
5181
5182 if (SetOrGet)
5183 {
5184 Ret = IntSetMenuItemInfo(Menu, MenuItem, &ItemInfo, lpstr);
5185 }
5186 else
5187 {
5188 Ret = IntGetMenuItemInfo(Menu, MenuItem, &ItemInfo);
5189 if (Ret)
5190 {
5191 Status = MmCopyToCaller(UnsafeItemInfo, &ItemInfo, Size);
5192 if (! NT_SUCCESS(Status))
5193 {
5195 return FALSE;
5196 }
5197 }
5198 }
5199
5200 return Ret;
5201}
#define SC_TASKLIST
Definition: winuser.h:2618

Referenced by NtUserThunkedMenuItemInfo().

◆ UserSetMenuDefaultItem()

BOOL FASTCALL UserSetMenuDefaultItem ( PMENU  MenuObject,
UINT  uItem,
UINT  fByPos 
)

Definition at line 1274 of file menu.c.

1275{
1276 UINT i;
1277 PITEM MenuItem = MenuObject->rgItems;
1278
1279 if (!MenuItem) return FALSE;
1280
1281 /* reset all default-item flags */
1282 for (i = 0; i < MenuObject->cItems; i++, MenuItem++)
1283 {
1284 MenuItem->fState &= ~MFS_DEFAULT;
1285 }
1286
1287 /* no default item */
1288 if(uItem == (UINT)-1)
1289 {
1290 return TRUE;
1291 }
1292 MenuItem = MenuObject->rgItems;
1293 if ( fByPos )
1294 {
1295 if ( uItem >= MenuObject->cItems ) return FALSE;
1296 MenuItem[uItem].fState |= MFS_DEFAULT;
1297 return TRUE;
1298 }
1299 else
1300 {
1301 for (i = 0; i < MenuObject->cItems; i++, MenuItem++)
1302 {
1303 if (MenuItem->wID == uItem)
1304 {
1305 MenuItem->fState |= MFS_DEFAULT;
1306 return TRUE;
1307 }
1308 }
1309
1310 }
1311 return FALSE;
1312}

Referenced by co_UserTrackSystemMenu(), IntSetMenuItemInfo(), MENU_GetSystemMenu(), MENU_InitSysMenuPopup(), and NtUserSetMenuDefaultItem().

◆ VerifyMenu()

PMENU FASTCALL VerifyMenu ( PMENU  pMenu)

Definition at line 201 of file menu.c.

202{
203 HMENU hMenu;
204 PITEM pItem;
205 ULONG Error;
206 UINT i;
207 if (!pMenu) return NULL;
208
210
212 {
213 hMenu = UserHMGetHandle(pMenu);
214 pItem = pMenu->rgItems;
215 if (pItem)
216 {
217 i = pItem[0].wID;
218 pItem[0].wID = i;
219 }
220 }
222 {
223 ERR("Run away LOOP!\n");
225 _SEH2_YIELD(return NULL);
226 }
228
229 if ( UserObjectInDestroy(hMenu))
230 {
231 ERR("Menu is marked for destruction!\n");
232 pMenu = NULL;
233 }
235 return pMenu;
236}
BOOL Error
Definition: chkdsk.c:66
ENGAPI ULONG APIENTRY EngGetLastError(VOID)
Definition: error.c:9

Referenced by MENU_FindItemByKey(), MENU_HideSubPopups(), MENU_TrackKbdMenuBar(), MENU_TrackMenu(), and MENU_TrackMouseMenuBar().

Variable Documentation

◆ fInEndMenu

BOOL fInEndMenu = FALSE

Definition at line 26 of file menu.c.

Referenced by MENU_EndMenu(), and MENU_InitTracking().

◆ fInsideMenuLoop

BOOL fInsideMenuLoop = FALSE

Definition at line 25 of file menu.c.

Referenced by MENU_EndMenu(), MENU_InitTracking(), MENU_TrackMenu(), and NtUserEndMenu().

◆ ghMenuFont

◆ ghMenuFontBold

HFONT ghMenuFontBold = NULL

Definition at line 17 of file menu.c.

Referenced by MENU_CalcItemSize(), MENU_DrawMenuItem(), and MenuInit().

◆ MenuCharSize

SIZE MenuCharSize
static

Definition at line 18 of file menu.c.

Referenced by MENU_CalcItemSize(), and MENU_DrawMenuItem().

◆ top_popup

◆ top_popup_hmenu