ReactOS 0.4.15-dev-8236-g99f0937
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
 

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 WINAPI IntTrackPopupMenuEx (PMENU menu, UINT wFlags, int x, int y, PWND pWnd, LPTPMPARAMS 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 APIENTRY NtUserTrackPopupMenuEx (HMENU hMenu, UINT fuFlags, int x, int y, HWND hWnd, 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:745
#define MFT_SEPARATOR
Definition: winuser.h:744
#define MFT_OWNERDRAW
Definition: winuser.h:741
#define MFT_BITMAP
Definition: winuser.h:738
#define MFT_RIGHTJUSTIFY
Definition: winuser.h:743
#define MFT_STRING
Definition: winuser.h:746
#define MFT_MENUBREAK
Definition: winuser.h:740
#define MFT_RADIOCHECK
Definition: winuser.h:742
#define MFT_MENUBARBREAK
Definition: winuser.h:739

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.

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}
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
static real win[4][36]
Definition: ntuser.h:694
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:4
int ret
_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:3004
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
static ATOM item
Definition: dde.c:856
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:224
struct _DESKTOP * rpdesk
Definition: ntuser.h:219
PROCDESKHEAD head
Definition: ntuser.h:417
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1255
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: debug.h:113
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:108
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:214
BOOL FASTCALL UserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2105
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define COLOR_MENU
Definition: winuser.h:917
#define ODA_DRAWENTIRE
Definition: winuser.h:2542
#define SM_CYMENU
Definition: winuser.h:976
#define COLOR_3DFACE
Definition: winuser.h:929

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:2584
#define SC_MINIMIZE
Definition: winuser.h:2586
#define SC_CLOSE
Definition: winuser.h:2592
#define SC_MOVE
Definition: winuser.h:2585
#define SC_RESTORE
Definition: winuser.h:2598
#define SC_MAXIMIZE
Definition: winuser.h:2588
#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 5033 of file menu.c.

5034{
5035 PMENU menu, pSubTarget;
5036 UINT Pos;
5037 if (((*hMenu)==(HMENU)0xffff) ||(!(menu = UserGetMenuObject(*hMenu))))
5038 return NO_SELECTED_ITEM;
5039
5040 pSubTarget = UserGetMenuObject(hSubTarget);
5041
5042 Pos = MENU_FindSubMenu(&menu, pSubTarget );
5043
5044 *hMenu = (menu ? UserHMGetHandle(menu) : NULL);
5045
5046 return Pos;
5047}
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:92
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(HDC hdc, PTEXTMETRICW ptm, PDWORD height)
Definition: font.c:329
#define DCX_CACHE
Definition: winuser.h:2114

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:2126
#define MFS_DISABLED
Definition: winuser.h:749
#define MFS_DEFAULT
Definition: winuser.h:748
#define GMDI_GOINTOPOPUPS
Definition: winuser.h:2125

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:32
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:727
#define MIIM_ID
Definition: winuser.h:722
#define MIIM_CHECKMARKS
Definition: winuser.h:724
#define MIIM_FTYPE
Definition: winuser.h:729
#define MIIM_STATE
Definition: winuser.h:721
#define MIIM_SUBMENU
Definition: winuser.h:723
#define MIIM_BITMAP
Definition: winuser.h:728
#define MIIM_DATA
Definition: winuser.h:726
#define MIIM_TYPE
Definition: winuser.h:725

Referenced by IntMenuItemInfo(), and UserMenuItemInfo().

◆ IntGetMenuItemRect()

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

Definition at line 5248 of file menu.c.

5253{
5254 LONG XMove, YMove;
5255 PITEM MenuItem;
5256 UINT I = uItem;
5257
5258 if ((MenuItem = MENU_FindItem (&Menu, &I, MF_BYPOSITION)))
5259 {
5260 Rect->left = MenuItem->xItem;
5261 Rect->top = MenuItem->yItem;
5262 Rect->right = MenuItem->cxItem; // Do this for now......
5263 Rect->bottom = MenuItem->cyItem;
5264 }
5265 else
5266 {
5267 ERR("Failed Item Lookup! %u\n", uItem);
5268 return FALSE;
5269 }
5270
5271 if (!pWnd)
5272 {
5273 HWND hWnd = Menu->hWnd;
5274 if (!(pWnd = UserGetWindowObject(hWnd))) return FALSE;
5275 }
5276
5277 if (Menu->fFlags & MNF_POPUP)
5278 {
5279 XMove = pWnd->rcClient.left;
5280 YMove = pWnd->rcClient.top;
5281 }
5282 else
5283 {
5284 XMove = pWnd->rcWindow.left;
5285 YMove = pWnd->rcWindow.top;
5286 }
5287
5288 Rect->left += XMove;
5289 Rect->top += YMove;
5290 Rect->right += XMove;
5291 Rect->bottom += YMove;
5292
5293 return TRUE;
5294}
#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:122

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

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

5014{
5015 PMENU MenuObject;
5016 PITEM pItem;
5017
5018 if (!(MenuObject = UserGetMenuObject(hMenu)))
5019 {
5020 return NULL;
5021 }
5022
5023 if (!(pItem = MENU_FindItem( &MenuObject, (UINT*)&nPos, MF_BYPOSITION ))) return NULL;
5024
5025 if (pItem->spSubMenu)
5026 {
5027 HMENU hsubmenu = UserHMGetHandle(pItem->spSubMenu);
5028 return hsubmenu;
5029 }
5030 return NULL;
5031}

Referenced by IntGetSystemMenu().

◆ IntGetSystemMenu()

PMENU FASTCALL IntGetSystemMenu ( PWND  Window,
BOOL  bRevert 
)

Definition at line 5401 of file menu.c.

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

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

◆ intGetTitleBarInfo()

BOOLEAN APIENTRY intGetTitleBarInfo ( PWND  pWindowObject,
PTITLEBARINFO  bti 
)

Definition at line 4822 of file menu.c.

4823{
4824
4825 DWORD dwStyle = 0;
4826 DWORD dwExStyle = 0;
4827 BOOLEAN retValue = TRUE;
4828
4829 if (bti->cbSize == sizeof(TITLEBARINFO))
4830 {
4831 RtlZeroMemory(&bti->rgstate[0],sizeof(DWORD)*(CCHILDREN_TITLEBAR+1));
4832
4834
4835 dwStyle = pWindowObject->style;
4836 dwExStyle = pWindowObject->ExStyle;
4837
4838 bti->rcTitleBar.top = 0;
4839 bti->rcTitleBar.left = 0;
4840 bti->rcTitleBar.right = pWindowObject->rcWindow.right - pWindowObject->rcWindow.left;
4841 bti->rcTitleBar.bottom = pWindowObject->rcWindow.bottom - pWindowObject->rcWindow.top;
4842
4843 /* Is it iconiced ? */
4844 if ((dwStyle & WS_ICONIC)!=WS_ICONIC)
4845 {
4846 /* Remove frame from rectangle */
4847 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
4848 {
4849 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXFRAME) and UserGetSystemMetrics(SM_CYFRAME) */
4851 }
4852 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
4853 {
4854 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXDLGFRAME) and UserGetSystemMetrics(SM_CYDLGFRAME) */
4856 }
4857 else if (HAS_THINFRAME( dwStyle, dwExStyle))
4858 {
4859 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
4861 }
4862
4863 /* We have additional border information if the window
4864 * is a child (but not an MDI child) */
4865 if ( (dwStyle & WS_CHILD) &&
4866 ((dwExStyle & WS_EX_MDICHILD) == 0 ) )
4867 {
4868 if (dwExStyle & WS_EX_CLIENTEDGE)
4869 {
4870 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXEDGE) and UserGetSystemMetrics(SM_CYEDGE) */
4872 }
4873
4874 if (dwExStyle & WS_EX_STATICEDGE)
4875 {
4876 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CXBORDER) and UserGetSystemMetrics(SM_CYBORDER) */
4878 }
4879 }
4880 }
4881
4882 bti->rcTitleBar.top += pWindowObject->rcWindow.top;
4883 bti->rcTitleBar.left += pWindowObject->rcWindow.left;
4884 bti->rcTitleBar.right += pWindowObject->rcWindow.left;
4885
4886 bti->rcTitleBar.bottom = bti->rcTitleBar.top;
4887 if (dwExStyle & WS_EX_TOOLWINDOW)
4888 {
4889 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CYSMCAPTION) */
4891 }
4892 else
4893 {
4894 /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CYCAPTION) and UserGetSystemMetrics(SM_CXSIZE) */
4897 }
4898
4899 if (dwStyle & WS_CAPTION)
4900 {
4902 if (dwStyle & WS_SYSMENU)
4903 {
4904 if (!(dwStyle & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX)))
4905 {
4908 }
4909 else
4910 {
4911 if (!(dwStyle & WS_MINIMIZEBOX))
4912 {
4914 }
4915 if (!(dwStyle & WS_MAXIMIZEBOX))
4916 {
4918 }
4919 }
4920
4921 if (!(dwExStyle & WS_EX_CONTEXTHELP))
4922 {
4924 }
4925 if (pWindowObject->pcls->style & CS_NOCLOSE)
4926 {
4928 }
4929 }
4930 else
4931 {
4936 }
4937 }
4938 else
4939 {
4941 }
4942 }
4943 else
4944 {
4946 retValue = FALSE;
4947 }
4948
4949 return retValue;
4950}
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:3762
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:1009
#define SM_CXEDGE
Definition: winuser.h:1008
#define SM_CXFRAME
Definition: winuser.h:994
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define CCHILDREN_TITLEBAR
Definition: winuser.h:3757
#define SM_CXSIZE
Definition: winuser.h:991
#define SM_CYFRAME
Definition: winuser.h:996
#define SM_CYBORDER
Definition: winuser.h:965
#define STATE_SYSTEM_FOCUSABLE
Definition: winuser.h:2882
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define SM_CXBORDER
Definition: winuser.h:964
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2877
#define SM_CXDLGFRAME
Definition: winuser.h:966
#define STATE_SYSTEM_UNAVAILABLE
Definition: winuser.h:2862
#define SM_CYSMCAPTION
Definition: winuser.h:1014
#define SM_CYDLGFRAME
Definition: winuser.h:968
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WS_EX_CONTEXTHELP
Definition: winuser.h:386
#define SM_CYCAPTION
Definition: winuser.h:963
#define CS_NOCLOSE
Definition: winuser.h:654

Referenced by NtUserGetTitleBarInfo().

◆ IntHiliteMenuItem()

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

Definition at line 4796 of file menu.c.

4800{
4801 PITEM MenuItem;
4802 UINT uItem = uItemHilite;
4803
4804 if (!(MenuItem = MENU_FindItem( &MenuObject, &uItem, uHilite ))) return TRUE;
4805
4806 if (uHilite & MF_HILITE)
4807 {
4808 MenuItem->fState |= MF_HILITE;
4809 }
4810 else
4811 {
4812 MenuItem->fState &= ~MF_HILITE;
4813 }
4814 if (MenuObject->iItem == uItemHilite) return TRUE;
4815 MENU_HideSubPopups( WindowObject, MenuObject, FALSE, 0 );
4816 MENU_SelectItem( WindowObject, MenuObject, uItemHilite, TRUE, 0 );
4817
4818 return TRUE; // Always returns true!!!!
4819}
static void FASTCALL MENU_HideSubPopups(PWND pWndOwner, PMENU Menu, BOOL SendMenuSelect, UINT wFlags)
Definition: menu.c:3269
static void FASTCALL MENU_SelectItem(PWND pwndOwner, PMENU menu, UINT wIndex, BOOL sendMenuSelect, PMENU topmenu)
Definition: menu.c:3146
#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:3310

Referenced by MENU_GetSystemMenu(), and UserInsertMenuItem().

◆ IntIsMenu()

BOOL FASTCALL IntIsMenu ( HMENU  Menu)

Definition at line 240 of file menu.c.

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

◆ IntMenuItemFromPoint()

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

Definition at line 1518 of file menu.c.

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

Referenced by IntDefWindowProc().

◆ IntMenuItemInfo()

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

Definition at line 5094 of file menu.c.

5101{
5102 PITEM MenuItem;
5103 BOOL Ret;
5104
5105 if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
5106 {
5108 return FALSE;
5109 }
5110 if (SetOrGet)
5111 {
5112 Ret = IntSetMenuItemInfo(Menu, MenuItem, ItemInfo, lpstr);
5113 }
5114 else
5115 {
5116 Ret = IntGetMenuItemInfo(Menu, MenuItem, ItemInfo);
5117 }
5118 return Ret;
5119}
_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
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

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

◆ IntSetMenu()

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

Definition at line 5477 of file menu.c.

5481{
5482 PMENU OldMenu, NewMenu = NULL;
5483
5484 if ((Wnd->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
5485 {
5486 ERR("SetMenu: Window is a Child 0x%p!\n",UserHMGetHandle(Wnd));
5488 return FALSE;
5489 }
5490
5491 *Changed = (UlongToHandle(Wnd->IDMenu) != Menu);
5492 if (! *Changed)
5493 {
5494 return TRUE;
5495 }
5496
5497 if (Wnd->IDMenu)
5498 {
5499 OldMenu = IntGetMenuObject(UlongToHandle(Wnd->IDMenu));
5500 ASSERT(NULL == OldMenu || OldMenu->hWnd == UserHMGetHandle(Wnd));
5501 }
5502 else
5503 {
5504 OldMenu = NULL;
5505 }
5506
5507 if (NULL != Menu)
5508 {
5509 NewMenu = IntGetMenuObject(Menu);
5510 if (NULL == NewMenu)
5511 {
5512 if (NULL != OldMenu)
5513 {
5514 IntReleaseMenuObject(OldMenu);
5515 }
5517 return FALSE;
5518 }
5519 if (NULL != NewMenu->hWnd)
5520 {
5521 /* Can't use the same menu for two windows */
5522 if (NULL != OldMenu)
5523 {
5524 IntReleaseMenuObject(OldMenu);
5525 }
5527 return FALSE;
5528 }
5529
5530 }
5531
5532 Wnd->IDMenu = (UINT_PTR) Menu;
5533 if (NULL != NewMenu)
5534 {
5535 NewMenu->hWnd = UserHMGetHandle(Wnd);
5536 IntReleaseMenuObject(NewMenu);
5537 }
5538 if (NULL != OldMenu)
5539 {
5540 OldMenu->hWnd = NULL;
5541 IntReleaseMenuObject(OldMenu);
5542 }
5543
5544 return TRUE;
5545}
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: debug.h:114
BOOL FASTCALL IntSetMenuInfo(PMENU Menu, PROSMENUINFO lpmi)
Definition: menu.c:914
#define MNS_MODELESS
Definition: winuser.h:756
#define MNS_DRAGDROP
Definition: winuser.h:757
#define MNS_AUTODISMISS
Definition: winuser.h:758

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:2640
#define HBMMENU_CALLBACK
Definition: winuser.h:2630
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3287

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

◆ IntSetSystemMenu()

BOOL FASTCALL IntSetSystemMenu ( PWND  Window,
PMENU  Menu 
)

Definition at line 5444 of file menu.c.

5445{
5446 PMENU OldMenu;
5447
5448 if (!(Window->style & WS_SYSMENU)) return FALSE;
5449
5450 if (Window->SystemMenu)
5451 {
5452 OldMenu = UserGetMenuObject(Window->SystemMenu);
5453 if (OldMenu)
5454 {
5455 OldMenu->fFlags &= ~MNF_SYSMENU;
5456 IntDestroyMenuObject(OldMenu, TRUE);
5457 }
5458 }
5459
5460 OldMenu = MENU_GetSystemMenu(Window, Menu);
5461 if (OldMenu)
5462 { // Use spmenuSys too!
5463 Window->SystemMenu = UserHMGetHandle(OldMenu);
5464 }
5465 else
5466 Window->SystemMenu = NULL;
5467
5468 if (Menu && Window != Menu->spwndNotify)
5469 {
5470 Menu->spwndNotify = Window;
5471 }
5472
5473 return TRUE;
5474}

Referenced by NtUserSetSystemMenu().

◆ IntTrackPopupMenuEx()

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

Definition at line 4579 of file menu.c.

4581{
4582 BOOL ret = FALSE;
4584
4585 if (pti != pWnd->head.pti)
4586 {
4587 ERR("Must be the same pti!\n");
4588 return ret;
4589 }
4590
4591 TRACE("hmenu %p flags %04x (%d,%d) hwnd %p lpTpm %p \n", //rect %s\n",
4592 UserHMGetHandle(menu), wFlags, x, y, UserHMGetHandle(pWnd), lpTpm); //,
4593 //lpTpm ? wine_dbgstr_rect( &lpTpm->rcExclude) : "-" );
4594
4595 if (menu->hWnd && IntIsWindow(menu->hWnd))
4596 {
4598 return FALSE;
4599 }
4600
4601 if (MENU_InitPopup( pWnd, menu, wFlags ))
4602 {
4603 MENU_InitTracking(pWnd, menu, TRUE, wFlags);
4604
4605 /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
4606 if (!(wFlags & TPM_NONOTIFY))
4607 {
4609 }
4610
4611 if (menu->fFlags & MNF_SYSMENU)
4612 MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
4613
4614 if (MENU_ShowPopup(pWnd, menu, 0, wFlags | TPM_POPUPMENU, x, y, lpTpm ? &lpTpm->rcExclude : NULL))
4615 ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd);
4616 else
4617 {
4619 pti->MessageQueue->QF_flags &= ~QF_CAPTURELOCKED;
4620 co_UserSetCapture(NULL); /* release the capture */
4621 }
4622
4624
4625 if (menu->hWnd)
4626 {
4627 PWND pwndM = ValidateHwndNoErr( menu->hWnd );
4628 if (pwndM) // wine hack around this with their destroy function.
4629 {
4630 if (!(pWnd->state & WNDS_DESTROYED))
4631 co_UserDestroyWindow( pwndM ); // Fix wrong error return.
4632 }
4633 menu->hWnd = 0;
4634
4635 if (!(wFlags & TPM_NONOTIFY))
4636 {
4637 co_IntSendMessage( UserHMGetHandle(pWnd), WM_UNINITMENUPOPUP, (WPARAM)UserHMGetHandle(menu),
4638 MAKELPARAM(0, IS_SYSTEM_MENU(menu) ? MF_SYSMENU : 0));
4639 }
4640 }
4641 }
4642 return ret;
4643}
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:3584
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2501
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
THRDESKHEAD head
Definition: ntuser.h:695
DWORD state
Definition: ntuser.h:701
RECT rcExclude
Definition: winuser.h:3576
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2853
#define IS_SYSTEM_MENU(MenuInfo)
Definition: menu.c:60
static BOOL MENU_InitPopup(PWND pWndOwner, PMENU menu, UINT flags)
Definition: menu.c:2781
static BOOL FASTCALL MENU_ExitTracking(PWND pWnd, BOOL bPopup, UINT wFlags)
Definition: menu.c:4466
#define TPM_POPUPMENU
Definition: menu.c:90
static BOOL FASTCALL MENU_ShowPopup(PWND pwndOwner, PMENU menu, UINT id, UINT flags, INT x, INT y, const RECT *pExclude)
Definition: menu.c:2939
void FASTCALL MENU_InitSysMenuPopup(PMENU menu, DWORD style, DWORD clsStyle, LONG HitTest)
Definition: menu.c:1362
static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y, PWND pwnd)
Definition: menu.c:4052
static BOOL FASTCALL MENU_InitTracking(PWND pWnd, PMENU Menu, BOOL bPopup, UINT wFlags)
Definition: menu.c:4406
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1445
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:176
UINT_PTR WPARAM
Definition: windef.h:207
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define MF_SYSMENU
Definition: winuser.h:141
#define TPM_NONOTIFY
Definition: winuser.h:2386
#define WM_INITMENUPOPUP
Definition: winuser.h:1746
#define HTSYSMENU
Definition: winuser.h:2477

Referenced by IntDefWindowProc(), and NtUserTrackPopupMenuEx().

◆ MENU_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 3560 of file menu.c.

3561{
3562 TRACE("%x PtMenu=%p\n", pmt, PtMenu);
3563
3564 if (PtMenu)
3565 {
3566 UINT id = 0;
3567 PITEM item;
3568
3569 // Special check for the icon system menu
3570 if (IS_SYSTEM_MENU(PtMenu) && !(PtMenu->fFlags & MNF_POPUP))
3571 {
3572 item = PtMenu->rgItems;
3573 }
3574 else
3575 {
3576 item = MENU_FindItemByCoords( PtMenu, pmt->Pt, &id );
3577 }
3578
3579 if (item)
3580 {
3581 if (PtMenu->iItem != id)
3582 MENU_SwitchTracking(pmt, PtMenu, id, Flags);
3583
3584 /* If the popup menu is not already "popped" */
3585 if (!(item->fState & MF_MOUSESELECT))
3586 {
3587 pmt->CurrentMenu = MENU_ShowSubPopup(pmt->OwnerWnd, PtMenu, FALSE, Flags);
3588 }
3589
3590 return TRUE;
3591 }
3592 /* Else the click was on the menu bar, finish the tracking */
3593 }
3594 return FALSE;
3595}
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:3323
static void FASTCALL MENU_SwitchTracking(MTRACKER *pmt, PMENU PtMenu, UINT Index, UINT wFlags)
Definition: menu.c:3535
#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 3605 of file menu.c.

3606{
3607 TRACE("%p pmenu=%x\n", pmt, PtMenu);
3608
3609 if (PtMenu)
3610 {
3611 UINT Id = 0;
3612 ITEM *item;
3613
3614 // Special check for the icon system menu
3615 if (IS_SYSTEM_MENU(PtMenu) && !(PtMenu->fFlags & MNF_POPUP))
3616 {
3617 item = PtMenu->rgItems;
3618 }
3619 else
3620 {
3621 item = MENU_FindItemByCoords( PtMenu, pmt->Pt, &Id );
3622 }
3623
3624 if (item && ( PtMenu->iItem == Id))
3625 {
3626 if (!(item->spSubMenu))
3627 {
3628 INT ExecutedMenuId = MENU_ExecFocusedItem( pmt, PtMenu, Flags);
3629 if (ExecutedMenuId == -1 || ExecutedMenuId == -2) return -1;
3630 return ExecutedMenuId;
3631 }
3632
3633 /* If we are dealing with the menu bar */
3634 /* and this is a click on an already "popped" item: */
3635 /* Stop the menu tracking and close the opened submenus */
3636 if (pmt->TopMenu == PtMenu && PtMenu->TimeToHide)
3637 {
3638 return 0;
3639 }
3640 }
3641 if ( IntGetMenu(PtMenu->hWnd) == PtMenu )
3642 {
3643 PtMenu->TimeToHide = TRUE;
3644 }
3645 }
3646 return -1;
3647}
DWORD Id
PMENU TopMenu
Definition: menu.c:82
static INT FASTCALL MENU_ExecFocusedItem(MTRACKER *pmt, PMENU Menu, UINT Flags)
Definition: menu.c:3480
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:3646
#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:1031
#define HBMMENU_MBAR_MINIMIZE
Definition: winuser.h:2633
#define DT_SINGLELINE
Definition: winuser.h:540
#define HBMMENU_MBAR_MINIMIZE_D
Definition: winuser.h:2636
#define MF_SEPARATOR
Definition: winuser.h:137
#define WM_MEASUREITEM
Definition: winuser.h:1646
#define MNS_NOCHECK
Definition: winuser.h:755
#define SM_CYMENUSIZE
Definition: winuser.h:1018
#define DT_CALCRECT
Definition: winuser.h:526
#define MF_OWNERDRAW
Definition: winuser.h:135
#define ODT_MENU
Definition: winuser.h:2537

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

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

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:3093
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:1264
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:705
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:2547
#define ODS_SELECTED
Definition: winuser.h:2545
#define HBMMENU_SYSTEM
Definition: winuser.h:2631
#define HBMMENU_MBAR_RESTORE
Definition: winuser.h:2632
#define ODS_CHECKED
Definition: winuser.h:2548
#define HBMMENU_POPUP_RESTORE
Definition: winuser.h:2638
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:926
#define DFCS_INACTIVE
Definition: winuser.h:502
#define SM_CYSMICON
Definition: winuser.h:1013
#define WM_DRAWITEM
Definition: winuser.h:1645
#define DFC_CAPTION
Definition: winuser.h:473
#define MF_DEFAULT
Definition: winuser.h:140
#define SM_CXSMICON
Definition: winuser.h:1012
#define HBMMENU_POPUP_CLOSE
Definition: winuser.h:2637
#define DFCS_CAPTIONRESTORE
Definition: winuser.h:483
#define HBMMENU_MBAR_CLOSE
Definition: winuser.h:2634
#define ODS_GRAYED
Definition: winuser.h:2546
#define HBMMENU_MBAR_CLOSE_D
Definition: winuser.h:2635
#define HBMMENU_POPUP_MAXIMIZE
Definition: winuser.h:2639
#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: ntvdm.h:50
#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:736
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:932
#define COLOR_WINDOWFRAME
Definition: winuser.h:919
#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:760
#define DT_LEFT
Definition: winuser.h:534
#define SM_CYMENUCHECK
Definition: winuser.h:1032
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define BF_TOP
Definition: winuser.h:455
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:927
#define COLOR_BTNSHADOW
Definition: winuser.h:930
#define DT_VCENTER
Definition: winuser.h:543
#define DT_RIGHT
Definition: winuser.h:538
#define COLOR_MENUTEXT
Definition: winuser.h:920
#define DFCS_MENUBULLET
Definition: winuser.h:487
#define COLOR_BTNHIGHLIGHT
Definition: winuser.h:935
#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
int FASTCALL GreGetBkMode(HDC)
Definition: dcutil.c:35
static const WCHAR dc[]
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(LOGFONTW *lplf)
Definition: font.c:23
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
BOOL FASTCALL GreTextOutW(HDC hdc, int nXStart, int nYStart, LPCWSTR lpString, int cchString)
Definition: text.c:61
#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:158
#define DFCS_MENUARROWDOWN
Definition: undocuser.h:159
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:1345
#define WM_CANCELMODE
Definition: winuser.h:1635

Referenced by IntDefWindowProc().

◆ MENU_EnsureMenuItemVisible()

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

Definition at line 3104 of file menu.c.

3105{
3107 if (lppop->dwArrowsOn)
3108 {
3109 ITEM *item = &lppop->rgItems[wIndex];
3110 UINT nMaxHeight = MENU_GetMaxPopupHeight(lppop);
3111 UINT nOldPos = lppop->iTop;
3112 RECT rc;
3113 UINT arrow_bitmap_height;
3114 PWND pWnd = ValidateHwndNoErr(lppop->hWnd);
3115
3116 IntGetClientRect(pWnd, &rc);
3117
3118 arrow_bitmap_height = gpsi->oembmi[OBI_DNARROW].cy;
3119
3120 rc.top += arrow_bitmap_height;
3121 rc.bottom -= arrow_bitmap_height;
3122
3123 nMaxHeight -= UserGetSystemMetrics(SM_CYBORDER) + 2 * arrow_bitmap_height;
3124 UserRefObjectCo(pWnd, &Ref);
3125 if (item->cyItem > lppop->iTop + nMaxHeight)
3126 {
3127 lppop->iTop = item->cyItem - nMaxHeight;
3128 IntScrollWindow(pWnd, 0, nOldPos - lppop->iTop, &rc, &rc);
3129 MENU_DrawScrollArrows(lppop, hdc);
3130 //ERR("Scroll Down iTop %d iMaxTop %d nMaxHeight %d\n",lppop->iTop,lppop->iMaxTop,nMaxHeight);
3131 }
3132 else if (item->yItem < lppop->iTop)
3133 {
3134 lppop->iTop = item->yItem;
3135 IntScrollWindow(pWnd, 0, nOldPos - lppop->iTop, &rc, &rc);
3136 MENU_DrawScrollArrows(lppop, hdc);
3137 //ERR("Scroll U