ReactOS 0.4.16-dev-109-gf4cb10f
menu.c File Reference
#include <user32.h>
Include dependency graph for menu.c:

Go to the source code of this file.

Macros

#define MM_SETMENUHANDLE   (WM_USER + 0)
 
#define MM_GETMENUHANDLE   (WM_USER + 1)
 
#define MENU_TYPE_MASK   (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)
 
#define MENU_ITEM_TYPE(flags)   ((flags) & MENU_TYPE_MASK)
 
#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_STRING_ITEM(flags)   (MF_STRING == MENU_ITEM_TYPE(flags))
 
#define IS_MAGIC_BITMAP(id)   ((id) && ((INT_PTR)(id) < 12) && ((INT_PTR)(id) >= -1))
 
#define GET_WORD(ptr)   (*(WORD *)(ptr))
 
#define GET_DWORD(ptr)   (*(DWORD *)(ptr))
 

Functions

BOOL WINAPI GdiValidateHandle (HGDIOBJ hobj)
 
 WINE_DEFAULT_DEBUG_CHANNEL (menu)
 
FORCEINLINE PMENU MENU_GetMenu (HMENU hMenu)
 
ITEMMENU_FindItem (HMENU *hmenu, UINT *nPos, UINT wFlags)
 
UINT FASTCALL IntGetMenuDefaultItem (PMENU Menu, BOOL fByPos, UINT gmdiFlags, DWORD *gismc)
 
static BOOL GetMenuItemInfo_common (HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOW lpmii, BOOL unicode)
 
LRESULT WINAPI PopupMenuWndProcW (HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI PopupMenuWndProcA (HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
static LPCSTR MENU_ParseResource (LPCSTR res, HMENU hMenu)
 
static LPCSTR MENUEX_ParseResource (LPCSTR res, HMENU hMenu)
 
static void MENU_mnu2mnuii (UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
 
static BOOL MENU_NormalizeMenuItemInfoStruct (const MENUITEMINFOW *pmii_in, MENUITEMINFOW *pmii_out)
 
BOOL MenuInit (VOID)
 
VOID MenuCleanup (VOID)
 
NTSTATUS WINAPI User32LoadSysMenuTemplateForKernel (PVOID Arguments, ULONG ArgumentLength)
 
NTSTATUS WINAPI User32CallLoadMenuFromKernel (PVOID Arguments, ULONG ArgumentLength)
 
BOOL WINAPI AppendMenuA (HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
 
BOOL WINAPI AppendMenuW (HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
 
DWORD WINAPI CheckMenuItem (HMENU hmenu, UINT uIDCheckItem, UINT uCheck)
 
BOOL WINAPI CheckMenuRadioItem (HMENU hMenu, UINT first, UINT last, UINT check, UINT bypos)
 
HMENU WINAPI CreateMenu (VOID)
 
HMENU WINAPI CreatePopupMenu (VOID)
 
BOOL WINAPI DrawMenuBar (HWND hWnd)
 
BOOL WINAPI EnableMenuItem (HMENU hMenu, UINT uIDEnableItem, UINT uEnable)
 
HMENU WINAPI GetMenu (HWND hWnd)
 
LONG WINAPI GetMenuCheckMarkDimensions (VOID)
 
DWORD WINAPI GetMenuContextHelpId (HMENU hmenu)
 
UINT WINAPI GetMenuDefaultItem (HMENU hMenu, UINT fByPos, UINT gmdiFlags)
 
BOOL WINAPI GetMenuInfo (HMENU hmenu, LPMENUINFO lpcmi)
 
int WINAPI GetMenuItemCount (HMENU hmenu)
 
UINT WINAPI GetMenuItemID (HMENU hMenu, int nPos)
 
BOOL WINAPI GetMenuItemInfoA (HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOA lpmii)
 
BOOL WINAPI GetMenuItemInfoW (HMENU hMenu, UINT Item, BOOL bypos, LPMENUITEMINFOW lpmii)
 
UINT WINAPI GetMenuState (HMENU hMenu, UINT uId, UINT uFlags)
 
int WINAPI GetMenuStringA (HMENU hMenu, UINT uIDItem, LPSTR lpString, int nMaxCount, UINT uFlag)
 
int WINAPI GetMenuStringW (HMENU hMenu, UINT uIDItem, LPWSTR lpString, int nMaxCount, UINT uFlag)
 
HMENU WINAPI GetSubMenu (HMENU hMenu, int nPos)
 
HMENU WINAPI GetSystemMenu (HWND hWnd, BOOL bRevert)
 
BOOL WINAPI InsertMenuA (HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
 
BOOL WINAPI InsertMenuItemA (HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOA lpmii)
 
BOOL WINAPI InsertMenuItemW (HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
 
BOOL WINAPI InsertMenuW (HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
 
BOOL WINAPI IsMenu (HMENU Menu)
 
HMENU WINAPI LoadMenuA (HINSTANCE hInstance, LPCSTR lpMenuName)
 
HMENU WINAPI LoadMenuIndirectA (CONST MENUTEMPLATE *lpMenuTemplate)
 
HMENU WINAPI LoadMenuIndirectW (CONST MENUTEMPLATE *lpMenuTemplate)
 
HMENU WINAPI LoadMenuW (HINSTANCE hInstance, LPCWSTR lpMenuName)
 
BOOL WINAPI ModifyMenuA (HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
 
BOOL WINAPI ModifyMenuW (HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
 
BOOL WINAPI SetMenu (HWND hWnd, HMENU hMenu)
 
BOOL WINAPI SetMenuInfo (HMENU hmenu, LPCMENUINFO lpcmi)
 
BOOL WINAPI SetMenuItemBitmaps (HMENU hMenu, UINT uPosition, UINT uFlags, HBITMAP hBitmapUnchecked, HBITMAP hBitmapChecked)
 
BOOL WINAPI SetMenuItemInfoA (HMENU hmenu, UINT item, BOOL bypos, LPCMENUITEMINFOA lpmii)
 
BOOL WINAPI SetMenuItemInfoW (HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
 
BOOL WINAPI SetSystemMenu (HWND hwnd, HMENU hMenu)
 
BOOL WINAPI TrackPopupMenu (HMENU Menu, UINT Flags, int x, int y, int Reserved, HWND Wnd, CONST RECT *Rect)
 
LRESULT WINAPI MenuWindowProcA (HWND hWnd, ULONG_PTR Result, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI MenuWindowProcW (HWND hWnd, ULONG_PTR Result, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI ChangeMenuW (HMENU hMenu, UINT cmd, LPCWSTR lpszNewItem, UINT cmdInsert, UINT flags)
 
BOOL WINAPI ChangeMenuA (HMENU hMenu, UINT cmd, LPCSTR lpszNewItem, UINT cmdInsert, UINT flags)
 

Variables

const struct builtin_class_descr POPUPMENU_builtin_class
 

Macro Definition Documentation

◆ GET_DWORD

#define GET_DWORD (   ptr)    (*(DWORD *)(ptr))

Definition at line 63 of file menu.c.

◆ GET_WORD

#define GET_WORD (   ptr)    (*(WORD *)(ptr))

Definition at line 60 of file menu.c.

◆ IS_MAGIC_BITMAP

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

Definition at line 43 of file menu.c.

◆ IS_STRING_ITEM

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

Definition at line 42 of file menu.c.

◆ MENU_ITEM_TYPE

#define MENU_ITEM_TYPE (   flags)    ((flags) & MENU_TYPE_MASK)

Definition at line 24 of file menu.c.

◆ MENU_TYPE_MASK

#define MENU_TYPE_MASK   (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)

Definition at line 22 of file menu.c.

◆ MENUITEMINFO_STATE_MASK

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

Definition at line 37 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:748
#define MFT_SEPARATOR
Definition: winuser.h:747
#define MFT_OWNERDRAW
Definition: winuser.h:744
#define MFT_BITMAP
Definition: winuser.h:741
#define MFT_RIGHTJUSTIFY
Definition: winuser.h:746
#define MFT_STRING
Definition: winuser.h:749
#define MFT_MENUBREAK
Definition: winuser.h:743
#define MFT_RADIOCHECK
Definition: winuser.h:745
#define MFT_MENUBARBREAK
Definition: winuser.h:742

Definition at line 28 of file menu.c.

◆ MII_STATE_MASK

Definition at line 39 of file menu.c.

◆ MM_GETMENUHANDLE

#define MM_GETMENUHANDLE   (WM_USER + 1)

Definition at line 20 of file menu.c.

◆ MM_SETMENUHANDLE

#define MM_SETMENUHANDLE   (WM_USER + 0)

Definition at line 19 of file menu.c.

◆ MNS_STYLE_MASK

◆ STATE_MASK

#define STATE_MASK   (~TYPE_MASK)

Definition at line 35 of file menu.c.

◆ TYPE_MASK

Definition at line 33 of file menu.c.

Function Documentation

◆ AppendMenuA()

BOOL WINAPI AppendMenuA ( HMENU  hMenu,
UINT  uFlags,
UINT_PTR  uIDNewItem,
LPCSTR  lpNewItem 
)

Definition at line 676 of file menu.c.

680{
681 MENUITEMINFOW mii;
683 BOOL res;
684
686
687 MENU_mnu2mnuii( uFlags, uIDNewItem, (LPCWSTR)lpNewItem, &mii, FALSE);
688
689 /* copy the text string, it will be one or the other */
690 if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
691 {
693 {
695 return FALSE;
696 }
697 mii.dwTypeData = UnicodeString.Buffer;
698 mii.cch = UnicodeString.Length / sizeof(WCHAR);
699 }
700 else
701 {
702 TRACE("AMA Handle bitmaps\n");
703 }
705 res = NtUserThunkedMenuItemInfo(hMenu, -1, TRUE, TRUE, &mii, &UnicodeString);
707 return res;
708}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT uFlags
Definition: api.c:59
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
BOOL NTAPI NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6560
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR dwTypeData
Definition: winuser.h:3272
static void MENU_mnu2mnuii(UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
Definition: menu.c:521
#define MIIM_STRING
Definition: winuser.h:730
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ AppendMenuW()

BOOL WINAPI AppendMenuW ( HMENU  hMenu,
UINT  uFlags,
UINT_PTR  uIDNewItem,
LPCWSTR  lpNewItem 
)

Definition at line 714 of file menu.c.

718{
719 MENUITEMINFOW mii;
720 UNICODE_STRING MenuText;
721 BOOL res;
722
723 RtlInitUnicodeString(&MenuText, 0);
724
725 MENU_mnu2mnuii( uFlags, uIDNewItem, lpNewItem, &mii, TRUE);
726
727 /* copy the text string, it will be one or the other */
728 if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
729 {
730 RtlInitUnicodeString(&MenuText, (PWSTR)mii.dwTypeData);
731 mii.dwTypeData = MenuText.Buffer;
732 mii.cch = MenuText.Length / sizeof(WCHAR);
733 }
734 res = NtUserThunkedMenuItemInfo(hMenu, -1, TRUE, TRUE, &mii, &MenuText);
735 return res;
736}
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by ChangeMenuW(), and MENU_ParseResource().

◆ ChangeMenuA()

BOOL WINAPI ChangeMenuA ( HMENU  hMenu,
UINT  cmd,
LPCSTR  lpszNewItem,
UINT  cmdInsert,
UINT  flags 
)

Definition at line 1744 of file menu.c.

1750{
1751 /*
1752 FIXME: Word passes the item id in 'cmd' and 0 or 0xffff as cmdInsert
1753 for MF_DELETE. We should check the parameters for all others
1754 MF_* actions also (anybody got a doc on ChangeMenu?).
1755 */
1756
1758 {
1759 case MF_APPEND :
1760 return AppendMenuA(hMenu, flags &~ MF_APPEND, cmdInsert, lpszNewItem);
1761
1762 case MF_DELETE :
1763 return DeleteMenu(hMenu, cmd, flags &~ MF_DELETE);
1764
1765 case MF_CHANGE :
1766 return ModifyMenuA(hMenu, cmd, flags &~ MF_CHANGE, cmdInsert, lpszNewItem);
1767
1768 case MF_REMOVE :
1769 return RemoveMenu(hMenu, flags & MF_BYPOSITION ? cmd : cmdInsert,
1770 flags &~ MF_REMOVE);
1771
1772 default : /* MF_INSERT */
1773 return InsertMenuA(hMenu, cmd, flags, cmdInsert, lpszNewItem);
1774 };
1775}
GLbitfield flags
Definition: glext.h:7161
Definition: ftp_var.h:139
#define MF_INSERT
Definition: winuser.h:146
#define MF_DELETE
Definition: winuser.h:149
#define MF_APPEND
Definition: winuser.h:148
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI InsertMenuA(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCSTR)
BOOL WINAPI ModifyMenuA(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCSTR)
#define MF_CHANGE
Definition: winuser.h:147
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI AppendMenuA(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCSTR)
#define MF_REMOVE
Definition: winuser.h:150

◆ ChangeMenuW()

BOOL WINAPI ChangeMenuW ( HMENU  hMenu,
UINT  cmd,
LPCWSTR  lpszNewItem,
UINT  cmdInsert,
UINT  flags 
)

Definition at line 1706 of file menu.c.

1712{
1713 /*
1714 FIXME: Word passes the item id in 'cmd' and 0 or 0xffff as cmdInsert
1715 for MF_DELETE. We should check the parameters for all others
1716 MF_* actions also (anybody got a doc on ChangeMenu?).
1717 */
1718
1720 {
1721 case MF_APPEND :
1722 return AppendMenuW(hMenu, flags &~ MF_APPEND, cmdInsert, lpszNewItem);
1723
1724 case MF_DELETE :
1725 return DeleteMenu(hMenu, cmd, flags &~ MF_DELETE);
1726
1727 case MF_CHANGE :
1728 return ModifyMenuW(hMenu, cmd, flags &~ MF_CHANGE, cmdInsert, lpszNewItem);
1729
1730 case MF_REMOVE :
1731 return RemoveMenu(hMenu, flags & MF_BYPOSITION ? cmd : cmdInsert,
1732 flags &~ MF_REMOVE);
1733
1734 default : /* MF_INSERT */
1735 return InsertMenuW(hMenu, cmd, flags, cmdInsert, lpszNewItem);
1736 };
1737}
BOOL WINAPI AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:714
BOOL WINAPI InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:1292
BOOL WINAPI ModifyMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)

◆ CheckMenuItem()

DWORD WINAPI CheckMenuItem ( HMENU  hmenu,
UINT  uIDCheckItem,
UINT  uCheck 
)

Definition at line 742 of file menu.c.

745{
746 PITEM item;
747 DWORD Ret;
748 UINT uID = uIDCheckItem;
749
751 return -1;
752
753 if (!(item = MENU_FindItem( &hmenu, &uID, uCheck ))) return -1;
754
755 Ret = item->fState & MFS_CHECKED;
756 if ( Ret == (uCheck & MFS_CHECKED)) return Ret; // Already Checked...
757
758 return NtUserCheckMenuItem(hmenu, uIDCheckItem, uCheck);
759}
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:377
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD NTAPI NtUserCheckMenuItem(HMENU hmenu, UINT uIDCheckItem, UINT uCheck)
Definition: menu.c:5600
@ TYPE_MENU
Definition: ntuser.h:42
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
static HMENU hmenu
Definition: win.c:66
#define MFS_CHECKED
Definition: winuser.h:750

◆ CheckMenuRadioItem()

BOOL WINAPI CheckMenuRadioItem ( HMENU  hMenu,
UINT  first,
UINT  last,
UINT  check,
UINT  bypos 
)

Definition at line 765 of file menu.c.

770{
771 BOOL done = FALSE;
772 UINT i;
773 PITEM mi_first = NULL, mi_check;
774 HMENU m_first, m_check;
775 MENUITEMINFOW mii;
776 mii.cbSize = sizeof( mii);
777
778 for (i = first; i <= last; i++)
779 {
780 UINT pos = i;
781
782 if (!mi_first)
783 {
784 m_first = hMenu;
785 mi_first = MENU_FindItem(&m_first, &pos, bypos);
786 if (!mi_first) continue;
787 mi_check = mi_first;
788 m_check = m_first;
789 }
790 else
791 {
792 m_check = hMenu;
793 mi_check = MENU_FindItem(&m_check, &pos, bypos);
794 if (!mi_check) continue;
795 }
796
797 if (m_first != m_check) continue;
798 if (mi_check->fType == MFT_SEPARATOR) continue;
799
800 if (i == check)
801 {
802 if (!(mi_check->fType & MFT_RADIOCHECK) || !(mi_check->fState & MFS_CHECKED))
803 {
805 mii.fType = (mi_check->fType & MENUITEMINFO_TYPE_MASK) | MFT_RADIOCHECK;
806 mii.fState = (mi_check->fState & MII_STATE_MASK) | MFS_CHECKED;
807 NtUserThunkedMenuItemInfo(m_check, i, bypos, FALSE, &mii, NULL);
808 }
809 done = TRUE;
810 }
811 else
812 {
813 /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
814 if (mi_check->fState & MFS_CHECKED)
815 {
816 mii.fMask = MIIM_STATE;
817 mii.fState = (mi_check->fState & MII_STATE_MASK) & ~MFS_CHECKED;
818 NtUserThunkedMenuItemInfo(m_check, i, bypos, FALSE, &mii, NULL);
819 }
820 }
821 }
822 return done;
823}
#define NULL
Definition: types.h:112
#define check(expected, result)
Definition: dplayx.c:32
const GLint * first
Definition: glext.h:5794
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
static UINT UINT last
Definition: font.c:45
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:47
#define MII_STATE_MASK
Definition: menu.c:39
#define MIIM_FTYPE
Definition: winuser.h:732
#define MIIM_STATE
Definition: winuser.h:724

◆ CreateMenu()

◆ CreatePopupMenu()

HMENU WINAPI CreatePopupMenu ( VOID  )

Definition at line 838 of file menu.c.

839{
840 return NtUserxCreatePopupMenu();
841}
EXTINLINE HMENU NtUserxCreatePopupMenu(VOID)
Definition: ntwrapper.h:556

Referenced by CBandSiteBase::_OnContextMenu(), _ShowContextMenu(), _ShowContextMenuR(), CMenuBand::_TrackContextMenu(), add_favs_to_menu(), CShellMenuCallback::AddOrSetMenuItem(), AdvProcDetailsDlgProc(), AppendMenuItems(), BrFolder_OnContextMenu(), BuildLeftPopupMenu(), CDesktopFolder::CallBack(), CDrivesFolder::CallBack(), CFSFolder::CallBack(), ConWndProc(), CDefView::DoColumnContextMenu(), DesktopShellView::DoDesktopContextMenu(), CDefView::Exec(), FileMenu_Create(), CDefView::FillFileMenu(), FM_InitMenuPopup(), handle_context_menu(), IFileDialogCustomize_fnAddMenu(), IFileDialogCustomize_fnEnableOpenDropDown(), CFolderItemVerbs::Init(), MENU_ParseResource(), MENUEX_ParseResource(), MONTHCAL_LButtonDown(), MONTHCAL_RButtonUp(), OleUIAddVerbMenuW(), CDeviceManager::OnCommand(), CDeviceView::OnContextMenu(), CDefView::OnContextMenu(), CDefView::OnExplorerCommand(), CInternetToolbar::OnMenuDropDown(), CISFBand::OnWinEvent(), CDefView::OpenSelectedItems(), COpenWithMenu::QueryContextMenu(), seltree_popup_menu(), SHELL_InvokePidl(), Shell_MergeMenus(), ShellExecute_ContextMenuVerb(), ShellFolderContextMenu(), SHInvokeCommand(), SHInvokeCommandOnContextMenuInternal(), ShowContextMenu(), ShowPowerSchemesPopupMenu(), START_TEST(), TaskManager_OnTabWndSelChange(), test_AppendMenu(), test_capture_4(), test_contextmenu(), test_CShellMenu_params(), test_emptypopup(), test_GetMenuItemRect(), test_mbs_help(), test_menu_cancelmode(), test_menu_circref(), test_menu_flags(), test_menu_hilitemenuitem(), test_menu_input(), test_menu_maxdepth(), test_menu_ownerdraw(), test_menu_trackagain(), test_menu_trackpopupmenu(), test_menualign(), test_OleUIAddVerbMenu(), test_subpopup_locked_by_menu(), test_TrackPopupMenu(), test_TrackPopupMenuEmpty(), CTrayWindow::TrackCtxMenu(), and wmain().

◆ DrawMenuBar()

BOOL WINAPI DrawMenuBar ( HWND  hWnd)

Definition at line 847 of file menu.c.

848{
849 return NtUserxDrawMenuBar(hWnd);
850}
HWND hWnd
Definition: settings.c:17
EXTINLINE BOOL NtUserxDrawMenuBar(HWND hWnd)
Definition: ntwrapper.h:778

◆ EnableMenuItem()

BOOL WINAPI EnableMenuItem ( HMENU  hMenu,
UINT  uIDEnableItem,
UINT  uEnable 
)

Definition at line 856 of file menu.c.

859{
860 return NtUserEnableMenuItem(hMenu, uIDEnableItem, uEnable);
861}
UINT NTAPI NtUserEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, UINT uEnable)
Definition: menu.c:5864

◆ GdiValidateHandle()

BOOL WINAPI GdiValidateHandle ( HGDIOBJ  hobj)

Definition at line 712 of file misc.c.

713{
715 if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 &&
717 GDI_HANDLE_GET_TYPE(hobj) )
718 {
719 HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
720 if(pid == NULL || pid == CurrentProcessId)
721 {
722 return TRUE;
723 }
724 }
725 return FALSE;
726
727}
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define GDI_HANDLE_TYPE_MASK
Definition: gdi.h:17
#define GDI_ENTRY_BASETYPE_MASK
Definition: ntgdihdl.h:34
#define GDI_ENTRY_UPPER_SHIFT
Definition: ntgdihdl.h:35
base of all file and directory entries
Definition: entries.h:83
Definition: gdi.h:2
PVOID HANDLE
Definition: typedefs.h:73
uint32_t ULONG_PTR
Definition: typedefs.h:65
PGDI_TABLE_ENTRY GdiHandleTable
Definition: misc.c:33
HANDLE CurrentProcessId
Definition: misc.c:35
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

Referenced by GetMenuItemInfo_common(), InsertMenuItemA(), InsertMenuItemW(), SetMenuItemInfoA(), and SetMenuItemInfoW().

◆ GetMenu()

HMENU WINAPI GetMenu ( HWND  hWnd)

Definition at line 867 of file menu.c.

868{
869 PWND Wnd = ValidateHwnd(hWnd);
870
871 if (!Wnd)
872 return NULL;
873
874 return UlongToHandle(Wnd->IDMenu);
875}
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
Definition: ntuser.h:694
UINT_PTR IDMenu
Definition: ntuser.h:731

◆ GetMenuCheckMarkDimensions()

LONG WINAPI GetMenuCheckMarkDimensions ( VOID  )

Definition at line 881 of file menu.c.

882{
885}
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define SM_CXMENUCHECK
Definition: winuser.h:1034
#define SM_CYMENUCHECK
Definition: winuser.h:1035
int WINAPI GetSystemMetrics(_In_ int)

◆ GetMenuContextHelpId()

DWORD WINAPI GetMenuContextHelpId ( HMENU  hmenu)

Definition at line 892 of file menu.c.

893{
894 PMENU pMenu;
895 if ((pMenu = ValidateHandle(hmenu, TYPE_MENU)))
896 return pMenu->dwContextHelpId;
897 return 0;
898}
DWORD dwContextHelpId
Definition: ntuser.h:428

◆ GetMenuDefaultItem()

UINT WINAPI GetMenuDefaultItem ( HMENU  hMenu,
UINT  fByPos,
UINT  gmdiFlags 
)

Definition at line 904 of file menu.c.

907{
908 PMENU pMenu;
909 DWORD gismc = 0;
910 if (!(pMenu = ValidateHandle(hMenu, TYPE_MENU)))
911 return (UINT)-1;
912
913 return IntGetMenuDefaultItem( pMenu, (BOOL)fByPos, gmdiFlags, &gismc);
914}
UINT FASTCALL IntGetMenuDefaultItem(PMENU MenuObject, UINT fByPos, UINT gmdiFlags, DWORD *gismc)
Definition: menu.c:1315

◆ GetMenuInfo()

BOOL WINAPI GetMenuInfo ( HMENU  hmenu,
LPMENUINFO  lpcmi 
)

Definition at line 920 of file menu.c.

922{
923 PMENU pMenu;
924
925 if (!lpcmi || (lpcmi->cbSize != sizeof(MENUINFO)))
926 {
928 return FALSE;
929 }
930
931 if (!(pMenu = ValidateHandle(hmenu, TYPE_MENU)))
932 return FALSE;
933
934 if (lpcmi->fMask & MIM_BACKGROUND)
935 lpcmi->hbrBack = pMenu->hbrBack;
936
937 if (lpcmi->fMask & MIM_HELPID)
938 lpcmi->dwContextHelpID = pMenu->dwContextHelpId;
939
940 if (lpcmi->fMask & MIM_MAXHEIGHT)
941 lpcmi->cyMax = pMenu->cyMax;
942
943 if (lpcmi->fMask & MIM_MENUDATA)
944 lpcmi->dwMenuData = pMenu->dwMenuData;
945
946 if (lpcmi->fMask & MIM_STYLE)
947 lpcmi->dwStyle = pMenu->fFlags & MNS_STYLE_MASK;
948
949 return TRUE;
950}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD dwStyle
Definition: winuser.h:3740
UINT cyMax
Definition: winuser.h:3741
HBRUSH hbrBack
Definition: winuser.h:3742
ULONG_PTR dwMenuData
Definition: winuser.h:3744
DWORD cbSize
Definition: winuser.h:3738
DWORD fMask
Definition: winuser.h:3739
DWORD dwContextHelpID
Definition: winuser.h:3743
ULONG fFlags
Definition: ntuser.h:418
DWORD_PTR dwMenuData
Definition: ntuser.h:430
ULONG cyMax
Definition: ntuser.h:429
HBRUSH hbrBack
Definition: ntuser.h:431
#define MNS_STYLE_MASK
Definition: menu.c:45

◆ GetMenuItemCount()

int WINAPI GetMenuItemCount ( HMENU  hmenu)

Definition at line 956 of file menu.c.

957{
958 PMENU pMenu;
959 if ((pMenu = ValidateHandle(hmenu, TYPE_MENU)))
960 return pMenu->cItems;
961 return -1;
962}
UINT cItems
Definition: ntuser.h:421

◆ GetMenuItemID()

UINT WINAPI GetMenuItemID ( HMENU  hMenu,
int  nPos 
)

Definition at line 968 of file menu.c.

970{
971 ITEM * lpmi;
972 if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return -1;
973 if (lpmi->spSubMenu) return -1;
974 return lpmi->wID;
975}
Definition: fontsub.cpp:36

◆ GetMenuItemInfo_common()

static BOOL GetMenuItemInfo_common ( HMENU  hmenu,
UINT  item,
BOOL  bypos,
LPMENUITEMINFOW  lpmii,
BOOL  unicode 
)
static

Definition at line 167 of file menu.c.

172{
173 ITEM *pItem = MENU_FindItem (&hmenu, &item, bypos ? MF_BYPOSITION : 0);
174
175 //debug_print_menuitem("GetMenuItemInfo_common: ", pItem, "");
176
177 if (!pItem)
178 {
180 return FALSE;
181 }
182
183 if( lpmii->fMask & MIIM_TYPE)
184 {
185 if( lpmii->fMask & ( MIIM_STRING | MIIM_FTYPE | MIIM_BITMAP))
186 {
187 ERR("invalid combination of fMask bits used\n");
188 /* this does not happen on Win9x/ME */
190 return FALSE;
191 }
192 lpmii->fType = pItem->fType & MENUITEMINFO_TYPE_MASK;
193 if (pItem->hbmp && !IS_MAGIC_BITMAP(pItem->hbmp))
194 lpmii->fType |= MFT_BITMAP;
195 lpmii->hbmpItem = pItem->hbmp; /* not on Win9x/ME */
196 if( lpmii->fType & MFT_BITMAP)
197 {
198 lpmii->dwTypeData = (LPWSTR) pItem->hbmp;
199 lpmii->cch = 0;
200 }
201 else if( lpmii->fType & (MFT_OWNERDRAW | MFT_SEPARATOR))
202 {
203 /* this does not happen on Win9x/ME */
204 lpmii->dwTypeData = 0;
205 lpmii->cch = 0;
206 }
207 }
208
209 /* copy the text string */
210 if ((lpmii->fMask & (MIIM_TYPE|MIIM_STRING)))
211 {
212 if( !pItem->Xlpstr )
213 { // Very strange this fixes a wine test with a crash.
214 if(lpmii->dwTypeData && lpmii->cch && !(GdiValidateHandle((HGDIOBJ)lpmii->dwTypeData)) )
215 {
216 if( unicode)
217 *((WCHAR *)lpmii->dwTypeData) = 0;
218 else
219 *((CHAR *)lpmii->dwTypeData) = 0;
220 }
221 lpmii->cch = 0;
222 }
223 else
224 {
225 int len;
226 LPWSTR text = DesktopPtrToUser(pItem->Xlpstr);
227 if (unicode)
228 {
229 len = strlenW(text);
230 if(lpmii->dwTypeData && lpmii->cch)
231 lstrcpynW(lpmii->dwTypeData, text, lpmii->cch);
232 }
233 else
234 {
235 len = WideCharToMultiByte( CP_ACP, 0, text, -1, NULL, 0, NULL, NULL ) - 1;
236 if(lpmii->dwTypeData && lpmii->cch)
237 if (!WideCharToMultiByte( CP_ACP, 0, text, -1,
238 (LPSTR)lpmii->dwTypeData, lpmii->cch, NULL, NULL ))
239 ((LPSTR)lpmii->dwTypeData)[lpmii->cch - 1] = 0;
240 }
241 /* if we've copied a substring we return its length */
242 if(lpmii->dwTypeData && lpmii->cch)
243 if (lpmii->cch <= len + 1)
244 lpmii->cch--;
245 else
246 lpmii->cch = len;
247 else
248 {
249 /* return length of string */
250 /* not on Win9x/ME if fType & MFT_BITMAP */
251 lpmii->cch = len;
252 }
253 }
254 }
255
256 if (lpmii->fMask & MIIM_FTYPE)
257 lpmii->fType = pItem->fType & MENUITEMINFO_TYPE_MASK;
258
259 if (lpmii->fMask & MIIM_BITMAP)
260 lpmii->hbmpItem = pItem->hbmp;
261
262 if (lpmii->fMask & MIIM_STATE)
263 lpmii->fState = pItem->fState & MENUITEMINFO_STATE_MASK;
264
265 if (lpmii->fMask & MIIM_ID)
266 lpmii->wID = pItem->wID;
267
268 if (lpmii->fMask & MIIM_SUBMENU && pItem->spSubMenu )
269 {
270 PMENU pSubMenu = DesktopPtrToUser(pItem->spSubMenu);
271 HMENU hSubMenu = UserHMGetHandle(pSubMenu);
272 lpmii->hSubMenu = hSubMenu;
273 }
274 else
275 {
276 /* hSubMenu is always cleared
277 * (not on Win9x/ME ) */
278 lpmii->hSubMenu = 0;
279 }
280
281 if (lpmii->fMask & MIIM_CHECKMARKS)
282 {
283 lpmii->hbmpChecked = pItem->hbmpChecked;
284 lpmii->hbmpUnchecked = pItem->hbmpUnchecked;
285 }
286 if (lpmii->fMask & MIIM_DATA)
287 lpmii->dwItemData = pItem->dwItemData;
288
289 return TRUE;
290}
#define ERR(fmt,...)
Definition: precomp.h:57
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define lstrcpynW
Definition: compat.h:738
static PVOID FASTCALL DesktopPtrToUser(PVOID ptr)
Definition: utils.c:324
GLenum GLsizei len
Definition: glext.h:6722
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
LPCSTR text
Definition: menu.c:77
#define strlenW(s)
Definition: unicode.h:34
ULONG_PTR dwItemData
Definition: winuser.h:3271
HBITMAP hbmpChecked
Definition: winuser.h:3269
HBITMAP hbmpUnchecked
Definition: winuser.h:3270
#define IS_MAGIC_BITMAP(id)
Definition: menu.c:63
#define MENUITEMINFO_STATE_MASK
Definition: menu.c:37
BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj)
Definition: misc.c:712
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937
#define MIIM_ID
Definition: winuser.h:725
#define MIIM_CHECKMARKS
Definition: winuser.h:727
#define MIIM_SUBMENU
Definition: winuser.h:726
#define MIIM_BITMAP
Definition: winuser.h:731
#define MIIM_DATA
Definition: winuser.h:729
#define MIIM_TYPE
Definition: winuser.h:728
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175

Referenced by GetMenuItemInfoA(), and GetMenuItemInfoW().

◆ GetMenuItemInfoA()

BOOL WINAPI GetMenuItemInfoA ( HMENU  hmenu,
UINT  item,
BOOL  bypos,
LPMENUITEMINFOA  lpmii 
)

Definition at line 981 of file menu.c.

986{
987 BOOL ret;
988 MENUITEMINFOA mii;
989
990 if( lpmii->cbSize != sizeof( mii) &&
991 lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem))
992 {
994 return FALSE;
995 }
996 memcpy( &mii, lpmii, lpmii->cbSize);
997 mii.cbSize = sizeof( mii);
999 item,
1000 bypos,
1001 (LPMENUITEMINFOW)&mii,
1002 FALSE);
1003 mii.cbSize = lpmii->cbSize;
1004 memcpy( lpmii, &mii, mii.cbSize);
1005 return ret;
1006}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int ret
static BOOL GetMenuItemInfo_common(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOW lpmii, BOOL unicode)
Definition: menu.c:167
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

◆ GetMenuItemInfoW()

BOOL WINAPI GetMenuItemInfoW ( HMENU  hMenu,
UINT  Item,
BOOL  bypos,
LPMENUITEMINFOW  lpmii 
)

Definition at line 1012 of file menu.c.

1017{
1018 BOOL ret;
1019 MENUITEMINFOW mii;
1020 if( lpmii->cbSize != sizeof( mii) && lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem))
1021 {
1023 return FALSE;
1024 }
1025 memcpy( &mii, lpmii, lpmii->cbSize);
1026 mii.cbSize = sizeof( mii);
1027 ret = GetMenuItemInfo_common (hMenu, Item, bypos, &mii, TRUE);
1028 mii.cbSize = lpmii->cbSize;
1029 memcpy( lpmii, &mii, mii.cbSize);
1030 return ret;
1031}
_In_ WDFCOLLECTION _In_ WDFOBJECT Item

◆ GetMenuState()

UINT WINAPI GetMenuState ( HMENU  hMenu,
UINT  uId,
UINT  uFlags 
)

Definition at line 1038 of file menu.c.

1042{
1043 PITEM pItem;
1044 UINT Type = 0;
1045 TRACE("(menu=%p, id=%04x, flags=%04x);\n", hMenu, uId, uFlags);
1046 if (!(pItem = MENU_FindItem( &hMenu, &uId, uFlags ))) return -1;
1047
1048 if (!pItem->Xlpstr && pItem->hbmp) Type = MFT_BITMAP;
1049
1050 if (pItem->spSubMenu)
1051 {
1052 PMENU pSubMenu = DesktopPtrToUser(pItem->spSubMenu);
1053 HMENU hsubmenu = UserHMGetHandle(pSubMenu);
1054 Type |= MF_POPUP; // Fix CORE-9269
1055 if (!IsMenu(hsubmenu)) return (UINT)-1;
1056 else return (pSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|Type) & 0xff);
1057 }
1058 else
1059 return (pItem->fType | pItem->fState | Type);
1060}
Type
Definition: Type.h:7
HBITMAP hbmp
Definition: ntuser.h:388
UINT fType
Definition: ntuser.h:372
USHORT * Xlpstr
Definition: ntuser.h:378
UINT fState
Definition: ntuser.h:373
struct tagMENU * spSubMenu
Definition: ntuser.h:375
BOOL WINAPI IsMenu(_In_ HMENU)
#define MF_POPUP
Definition: winuser.h:136

◆ GetMenuStringA()

int WINAPI GetMenuStringA ( HMENU  hMenu,
UINT  uIDItem,
LPSTR  lpString,
int  nMaxCount,
UINT  uFlag 
)

Definition at line 1067 of file menu.c.

1073{
1074 ITEM *item;
1075 LPWSTR text;
1077 TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, uIDItem, lpString, nMaxCount, uFlag );
1078
1079 if (lpString && nMaxCount) lpString[0] = '\0';
1080
1081 if (!(item = MENU_FindItem( &hMenu, &uIDItem, uFlag )))
1082 {
1084 return 0;
1085 }
1086
1087 text = item->Xlpstr ? DesktopPtrToUser(item->Xlpstr) : NULL;
1088
1089 if (!text) return 0;
1090 if (!lpString || !nMaxCount) return WideCharToMultiByte( CP_ACP, 0, text, -1, NULL, 0, NULL, NULL );
1091 if (!WideCharToMultiByte( CP_ACP, 0, text, -1, lpString, nMaxCount, NULL, NULL ))
1092 lpString[nMaxCount-1] = 0;
1093 TRACE("A returning %s\n", lpString);
1094 return strlen(lpString);
1095}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_In_ int nMaxCount
Definition: winuser.h:4880

◆ GetMenuStringW()

int WINAPI GetMenuStringW ( HMENU  hMenu,
UINT  uIDItem,
LPWSTR  lpString,
int  nMaxCount,
UINT  uFlag 
)

Definition at line 1102 of file menu.c.

1108{
1109 ITEM *item;
1110 LPWSTR text;
1111
1112 TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, uIDItem, lpString, nMaxCount, uFlag );
1113
1114 if (lpString && nMaxCount) lpString[0] = '\0';
1115
1116 if (!(item = MENU_FindItem( &hMenu, &uIDItem, uFlag )))
1117 {
1119 return 0;
1120 }
1121
1122 text = item->Xlpstr ? DesktopPtrToUser(item->Xlpstr) : NULL;
1123
1124 if (!lpString || !nMaxCount) return text ? strlenW(text) : 0;
1125 if( !(text))
1126 {
1127 lpString[0] = 0;
1128 return 0;
1129 }
1130 lstrcpynW( lpString, text, nMaxCount );
1131 TRACE("W returning %S\n", lpString);
1132 return strlenW(lpString);
1133}

◆ GetSubMenu()

HMENU WINAPI GetSubMenu ( HMENU  hMenu,
int  nPos 
)

Definition at line 1140 of file menu.c.

1143{
1144 PITEM pItem;
1145 if (!(pItem = MENU_FindItem( &hMenu, (UINT*)&nPos, MF_BYPOSITION ))) return NULL;
1146
1147 if (pItem->spSubMenu)
1148 {
1149 PMENU pSubMenu = DesktopPtrToUser(pItem->spSubMenu);
1150 HMENU hsubmenu = UserHMGetHandle(pSubMenu);
1151 if (IsMenu(hsubmenu)) return hsubmenu;
1152 }
1153 return NULL;
1154}

◆ GetSystemMenu()

HMENU WINAPI GetSystemMenu ( HWND  hWnd,
BOOL  bRevert 
)

Definition at line 1161 of file menu.c.

1162{
1163 return NtUserGetSystemMenu(hWnd, bRevert);
1164}
HMENU NTAPI NtUserGetSystemMenu(HWND hWnd, BOOL bRevert)
Definition: menu.c:5676

◆ InsertMenuA()

BOOL WINAPI InsertMenuA ( HMENU  hMenu,
UINT  uPosition,
UINT  uFlags,
UINT_PTR  uIDNewItem,
LPCSTR  lpNewItem 
)

Definition at line 1171 of file menu.c.

1177{
1178 MENUITEMINFOW mii;
1180 BOOL res;
1181
1183
1184 MENU_mnu2mnuii( uFlags, uIDNewItem, (LPCWSTR)lpNewItem, &mii, FALSE);
1185
1186 /* copy the text string, it will be one or the other */
1187 if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1188 {
1190 {
1192 return FALSE;
1193 }
1194 mii.dwTypeData = UnicodeString.Buffer;
1195 mii.cch = UnicodeString.Length / sizeof(WCHAR);
1196 }
1197 else
1198 {
1199 TRACE("Handle bitmaps\n");
1200 }
1201 res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), TRUE, &mii, &UnicodeString);
1203 return res;
1204}

◆ InsertMenuItemA()

BOOL WINAPI InsertMenuItemA ( HMENU  hMenu,
UINT  uItem,
BOOL  fByPosition,
LPCMENUITEMINFOA  lpmii 
)

Definition at line 1211 of file menu.c.

1216{
1217 MENUITEMINFOW mii;
1219 BOOL res;
1220
1221 TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, fByPosition, lpmii);
1222
1224
1225 if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &mii )) return FALSE;
1226
1227 /* copy the text string */
1228 if (((mii.fMask & MIIM_STRING) ||
1229 ((mii.fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(mii.fType) == MF_STRING)))
1230 && mii.dwTypeData && !(GdiValidateHandle((HGDIOBJ)mii.dwTypeData)) )
1231 {
1233 {
1235 return FALSE;
1236 }
1237 mii.dwTypeData = UnicodeString.Buffer;
1238 mii.cch = UnicodeString.Length / sizeof(WCHAR);
1239 }
1240 else
1241 {
1242 TRACE("Handle bitmaps\n");
1243 }
1244 res = NtUserThunkedMenuItemInfo(hMenu, uItem, fByPosition, TRUE, &mii, &UnicodeString);
1246 return res;
1247}
#define MENU_ITEM_TYPE(flags)
Definition: menu.h:6
static BOOL MENU_NormalizeMenuItemInfoStruct(const MENUITEMINFOW *pmii_in, MENUITEMINFOW *pmii_out)
Definition: menu.c:580
#define MF_STRING
Definition: winuser.h:138

◆ InsertMenuItemW()

BOOL WINAPI InsertMenuItemW ( HMENU  hMenu,
UINT  uItem,
BOOL  fByPosition,
LPCMENUITEMINFOW  lpmii 
)

Definition at line 1254 of file menu.c.

1259{
1260 MENUITEMINFOW mii;
1261 UNICODE_STRING MenuText;
1262 BOOL res = FALSE;
1263
1264 /* while we could just pass 'lpmii' to win32k, we make a copy so that
1265 if a bad user passes bad data, we crash his process instead of the
1266 entire kernel */
1267
1268 TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, fByPosition, lpmii);
1269
1270 RtlInitUnicodeString(&MenuText, 0);
1271
1272 if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &mii )) return FALSE;
1273
1274 /* copy the text string */
1275 if (((mii.fMask & MIIM_STRING) ||
1276 ((mii.fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(mii.fType) == MF_STRING)))
1277 && mii.dwTypeData && !(GdiValidateHandle((HGDIOBJ)mii.dwTypeData)) )
1278 {
1279 RtlInitUnicodeString(&MenuText, (PWSTR)lpmii->dwTypeData);
1280 mii.dwTypeData = MenuText.Buffer;
1281 mii.cch = MenuText.Length / sizeof(WCHAR);
1282 }
1283 res = NtUserThunkedMenuItemInfo(hMenu, uItem, fByPosition, TRUE, &mii, &MenuText);
1284 return res;
1285}

◆ InsertMenuW()

BOOL WINAPI InsertMenuW ( HMENU  hMenu,
UINT  uPosition,
UINT  uFlags,
UINT_PTR  uIDNewItem,
LPCWSTR  lpNewItem 
)

Definition at line 1292 of file menu.c.

1298{
1299 MENUITEMINFOW mii;
1300 UNICODE_STRING MenuText;
1301 BOOL res;
1302
1303 RtlInitUnicodeString(&MenuText, 0);
1304
1305 MENU_mnu2mnuii( uFlags, uIDNewItem, lpNewItem, &mii, TRUE);
1306
1307 /* copy the text string, it will be one or the other */
1308 if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1309 {
1310 RtlInitUnicodeString(&MenuText, (PWSTR)mii.dwTypeData);
1311 mii.dwTypeData = MenuText.Buffer;
1312 mii.cch = MenuText.Length / sizeof(WCHAR);
1313 }
1314 res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), TRUE, &mii, &MenuText);
1315 return res;
1316}

Referenced by ChangeMenuW().

◆ IntGetMenuDefaultItem()

UINT FASTCALL IntGetMenuDefaultItem ( PMENU  Menu,
BOOL  fByPos,
UINT  gmdiFlags,
DWORD gismc 
)

Definition at line 136 of file menu.c.

137{
138 UINT i = 0;
139 PITEM Item = Menu->rgItems ? DesktopPtrToUser(Menu->rgItems) : NULL;
140
141 /* empty menu */
142 if (!Item) return -1;
143
144 while ( !( Item->fState & MFS_DEFAULT ) )
145 {
146 i++; Item++;
147 if (i >= Menu->cItems ) return -1;
148 }
149
150 /* default: don't return disabled items */
151 if ( (!(GMDI_USEDISABLED & gmdiFlags)) && (Item->fState & MFS_DISABLED )) return -1;
152
153 /* search rekursiv when needed */
154 if ( (gmdiFlags & GMDI_GOINTOPOPUPS) && Item->spSubMenu )
155 {
156 UINT ret;
157 (*gismc)++;
158 ret = IntGetMenuDefaultItem( DesktopPtrToUser(Item->spSubMenu), fByPos, gmdiFlags, gismc );
159 (*gismc)--;
160 if ( -1 != ret ) return ret;
161
162 /* when item not found in submenu, return the popup item */
163 }
164 return ( fByPos ) ? i : Item->wID;
165}
PITEM rgItems
Definition: ntuser.h:426
#define GMDI_USEDISABLED
Definition: winuser.h:2129
#define MFS_DISABLED
Definition: winuser.h:752
#define MFS_DEFAULT
Definition: winuser.h:751
#define GMDI_GOINTOPOPUPS
Definition: winuser.h:2128

◆ IsMenu()

BOOL WINAPI IsMenu ( HMENU  Menu)

Definition at line 1323 of file menu.c.

1325{
1326 if (ValidateHandle(Menu, TYPE_MENU)) return TRUE;
1327 return FALSE;
1328}

◆ LoadMenuA()

HMENU WINAPI LoadMenuA ( HINSTANCE  hInstance,
LPCSTR  lpMenuName 
)

Definition at line 1334 of file menu.c.

1336{
1338 if (Resource == NULL)
1339 {
1340 return(NULL);
1341 }
1343}
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
HINSTANCE hInstance
Definition: charmap.c:19
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
HMENU WINAPI LoadMenuIndirectA(_In_ const MENUTEMPLATE *)

◆ LoadMenuIndirectA()

HMENU WINAPI LoadMenuIndirectA ( CONST MENUTEMPLATE lpMenuTemplate)

Definition at line 1349 of file menu.c.

1350{
1351 return(LoadMenuIndirectW(lpMenuTemplate));
1352}
HMENU WINAPI LoadMenuIndirectW(CONST MENUTEMPLATE *lpMenuTemplate)
Definition: menu.c:1358

◆ LoadMenuIndirectW()

HMENU WINAPI LoadMenuIndirectW ( CONST MENUTEMPLATE lpMenuTemplate)

Definition at line 1358 of file menu.c.

1359{
1360 HMENU hMenu;
1362 LPCSTR p = (LPCSTR)lpMenuTemplate;
1363
1364 version = GET_WORD(p);
1365 p += sizeof(WORD);
1366
1367 switch (version)
1368 {
1369 case 0: /* standard format is version of 0 */
1370 offset = GET_WORD(p);
1371 p += sizeof(WORD) + offset;
1372 if (!(hMenu = CreateMenu())) return 0;
1373 if (!MENU_ParseResource(p, hMenu))
1374 {
1375 DestroyMenu(hMenu);
1376 return 0;
1377 }
1378 return hMenu;
1379 case 1: /* extended format is version of 1 */
1380 offset = GET_WORD(p);
1381 p += sizeof(WORD) + offset;
1382 if (!(hMenu = CreateMenu())) return 0;
1383 if (!MENUEX_ParseResource(p, hMenu))
1384 {
1385 DestroyMenu( hMenu );
1386 return 0;
1387 }
1388 return hMenu;
1389 default:
1390 ERR("Menu template version %d not supported.\n", version);
1391 return 0;
1392 }
1393}
static const WCHAR version[]
Definition: asmname.c:66
unsigned short WORD
Definition: ntddk_ex.h:93
GLfloat GLfloat p
Definition: glext.h:8902
GLintptr offset
Definition: glext.h:5920
#define GET_WORD(ptr)
Definition: menu.c:60
static LPCSTR MENU_ParseResource(LPCSTR res, HMENU hMenu)
Definition: menu.c:410
static LPCSTR MENUEX_ParseResource(LPCSTR res, HMENU hMenu)
Definition: menu.c:455
HMENU WINAPI CreateMenu(void)
Definition: menu.c:829
BOOL WINAPI DestroyMenu(_In_ HMENU)
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by LoadMenuIndirectA(), and LoadMenuW().

◆ LoadMenuW()

HMENU WINAPI LoadMenuW ( HINSTANCE  hInstance,
LPCWSTR  lpMenuName 
)

Definition at line 1399 of file menu.c.

1401{
1403 if (Resource == NULL)
1404 {
1405 return(NULL);
1406 }
1408}
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
#define RT_MENU
Definition: pedump.c:366

Referenced by User32CallLoadMenuFromKernel().

◆ MENU_FindItem()

ITEM * MENU_FindItem ( HMENU hmenu,
UINT nPos,
UINT  wFlags 
)

Definition at line 83 of file menu.c.

84{
85 MENU *menu;
86 ITEM *fallback = NULL;
87 UINT fallback_pos = 0;
88 UINT i;
89 PITEM pItem;
90
91 if ((*hmenu == (HMENU)0xffff) || (!(menu = MENU_GetMenu(*hmenu)))) return NULL;
93 {
94 if (*nPos >= menu->cItems) return NULL;
95 pItem = menu->rgItems ? DesktopPtrToUser(menu->rgItems) : NULL;
96 if (pItem) pItem = &pItem[*nPos];
97 return pItem;
98 }
99 else
100 {
101 PITEM item = menu->rgItems ? DesktopPtrToUser(menu->rgItems) : NULL;
102 for (i = 0; item && (i < menu->cItems); i++, item++)
103 {
104 if (item->spSubMenu)
105 {
106 PMENU pSubMenu = DesktopPtrToUser(item->spSubMenu);
107 HMENU hsubmenu = UserHMGetHandle(pSubMenu);
108 ITEM *subitem = MENU_FindItem( &hsubmenu, nPos, wFlags );
109 if (subitem)
110 {
111 *hmenu = hsubmenu;
112 return subitem;
113 }
114 else if (item->wID == *nPos)
115 {
116 /* fallback to this item if nothing else found */
117 fallback_pos = i;
118 fallback = item;
119 }
120 }
121 else if (item->wID == *nPos)
122 {
123 *nPos = i;
124 return item;
125 }
126 }
127 }
128
129 if (fallback)
130 *nPos = fallback_pos;
131
132 return fallback;
133}
FORCEINLINE PMENU MENU_GetMenu(HMENU hMenu)
Definition: menu.c:72
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

◆ MENU_GetMenu()

FORCEINLINE PMENU MENU_GetMenu ( HMENU  hMenu)

Definition at line 72 of file menu.c.

73{
74 return ValidateHandleNoErr(hMenu, TYPE_MENU);
75}
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:338

Referenced by MENU_FindItem(), and MENU_mnu2mnuii().

◆ MENU_mnu2mnuii()

static void MENU_mnu2mnuii ( UINT  flags,
UINT_PTR  id,
LPCWSTR  str,
LPMENUITEMINFOW  pmii,
BOOL  Unicode 
)
static

Definition at line 521 of file menu.c.

522{
523 RtlZeroMemory( pmii, sizeof( MENUITEMINFOW));
524 pmii->cbSize = sizeof( MENUITEMINFOW);
526 /* setting bitmap clears text and vice versa */
527 if( IS_STRING_ITEM(flags)) {
528 pmii->fMask |= MIIM_STRING | MIIM_BITMAP;
529 if( !str)
531 /* Item beginning with a backspace is a help item */
532 /* FIXME: wrong place, this is only true in win16 */
533 else
534 {
535 if (Unicode)
536 {
537 if (*str == '\b')
538 {
539 flags |= MF_HELP;
540 str++;
541 }
542 }
543 else
544 {
545 LPCSTR NewItemA = (LPCSTR) str;
546 if (*NewItemA == '\b')
547 {
548 flags |= MF_HELP;
549 NewItemA++;
550 str = (LPCWSTR) NewItemA;
551 }
552 TRACE("A cch %d\n",strlen(NewItemA));
553 }
554 }
555 pmii->dwTypeData = (LPWSTR)str;
556 } else if( flags & MFT_BITMAP){
557 pmii->fMask |= MIIM_BITMAP | MIIM_STRING;
558 pmii->hbmpItem = (HBITMAP)str;
559 }
560 if( flags & MF_OWNERDRAW){
561 pmii->fMask |= MIIM_DATA;
562 pmii->dwItemData = (ULONG_PTR) str;
563 }
564 if( flags & MF_POPUP && MENU_GetMenu((HMENU)id)) {
565 pmii->fMask |= MIIM_SUBMENU;
566 pmii->hSubMenu = (HMENU)id;
567 }
569 pmii->fState = flags & MENUITEMINFO_STATE_MASK & ~MFS_DEFAULT;
571 pmii->wID = (UINT)id;
572}
#define ULONG_PTR
Definition: config.h:101
GLuint id
Definition: glext.h:5910
static HBITMAP
Definition: button.c:44
const WCHAR * str
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IS_STRING_ITEM(flags)
Definition: menu.c:64
#define MF_SEPARATOR
Definition: winuser.h:137
#define MF_HELP
Definition: winuser.h:142
#define MF_OWNERDRAW
Definition: winuser.h:135
struct tagMENUITEMINFOW MENUITEMINFOW
#define MF_GRAYED
Definition: winuser.h:129
#define MF_DISABLED
Definition: winuser.h:130

Referenced by AppendMenuA(), AppendMenuW(), InsertMenuA(), InsertMenuW(), ModifyMenuA(), and ModifyMenuW().

◆ MENU_NormalizeMenuItemInfoStruct()

static BOOL MENU_NormalizeMenuItemInfoStruct ( const MENUITEMINFOW pmii_in,
MENUITEMINFOW pmii_out 
)
static

Definition at line 580 of file menu.c.

582{
583 /* do we recognize the size? */
584 if( !pmii_in || (pmii_in->cbSize != sizeof( MENUITEMINFOW) &&
585 pmii_in->cbSize != sizeof( MENUITEMINFOW) - sizeof( pmii_in->hbmpItem)) ) {
587 return FALSE;
588 }
589 /* copy the fields that we have */
590 memcpy( pmii_out, pmii_in, pmii_in->cbSize);
591 /* if the hbmpItem member is missing then extend */
592 if( pmii_in->cbSize != sizeof( MENUITEMINFOW)) {
593 pmii_out->cbSize = sizeof( MENUITEMINFOW);
594 pmii_out->hbmpItem = NULL;
595 }
596 /* test for invalid bit combinations */
597 if( (pmii_out->fMask & MIIM_TYPE &&
598 pmii_out->fMask & (MIIM_STRING | MIIM_FTYPE | MIIM_BITMAP)) ||
599 (pmii_out->fMask & MIIM_FTYPE && pmii_out->fType & MFT_BITMAP)) {
600 ERR("invalid combination of fMask bits used\n");
601 /* this does not happen on Win9x/ME */
603 return FALSE;
604 }
605 /* convert old style (MIIM_TYPE) to the new and keep the old one too */
606 if( pmii_out->fMask & MIIM_TYPE){
607 pmii_out->fMask |= MIIM_FTYPE;
608 if( IS_STRING_ITEM(pmii_out->fType)){
609 pmii_out->fMask |= MIIM_STRING;
610 } else if( (pmii_out->fType) & MFT_BITMAP){
611 pmii_out->fMask |= MIIM_BITMAP;
612 pmii_out->hbmpItem = UlongToHandle(LOWORD(pmii_out->dwTypeData));
613 }
614 }
615 if (pmii_out->fMask & MIIM_FTYPE )
616 {
617 pmii_out->fType &= ~MENUITEMINFO_TYPE_MASK;
618 pmii_out->fType |= pmii_in->fType & MENUITEMINFO_TYPE_MASK;
619 }
620 if (pmii_out->fMask & MIIM_STATE)
621 /* Other menu items having MFS_DEFAULT are not converted
622 to normal items */
623 pmii_out->fState = pmii_in->fState & MENUITEMINFO_STATE_MASK;
624
625 if (pmii_out->fMask & MIIM_SUBMENU)
626 {
627 if ((pmii_out->hSubMenu != NULL) && !IsMenu(pmii_out->hSubMenu))
628 return FALSE;
629 }
630
631 return TRUE;
632}
#define LOWORD(l)
Definition: pedump.c:82

Referenced by InsertMenuItemA(), InsertMenuItemW(), SetMenuItemInfoA(), and SetMenuItemInfoW().

◆ MENU_ParseResource()

static LPCSTR MENU_ParseResource ( LPCSTR  res,
HMENU  hMenu 
)
static

Definition at line 410 of file menu.c.

411{
412 WORD flags, id = 0;
413 HMENU hSubMenu;
414 LPCWSTR str;
415 BOOL end = FALSE;
416
417 do
418 {
419 flags = GET_WORD(res);
420
421 /* remove MF_END flag before passing it to AppendMenu()! */
422 end = (flags & MF_END);
423 if(end) flags ^= MF_END;
424
425 res += sizeof(WORD);
426 if(!(flags & MF_POPUP))
427 {
428 id = GET_WORD(res);
429 res += sizeof(WORD);
430 }
431 str = (LPCWSTR)res;
432 res += (strlenW(str) + 1) * sizeof(WCHAR);
433
434 if (flags & MF_POPUP)
435 {
436 hSubMenu = CreatePopupMenu();
437 if(!hSubMenu) return NULL;
438 if(!(res = MENU_ParseResource(res, hSubMenu))) return NULL;
439 AppendMenuW(hMenu, flags, (UINT_PTR)hSubMenu, (LPCWSTR)str);
440 }
441 else /* Not a popup */
442 {
443 AppendMenuW(hMenu, flags, id, *(LPCWSTR)str ? (LPCWSTR)str : NULL);
444 }
445 } while(!end);
446 return res;
447}
GLuint GLuint end
Definition: gl.h:1545
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define MF_END
Definition: winuser.h:143

Referenced by LoadMenuIndirectW(), and MENU_ParseResource().

◆ MenuCleanup()

Definition at line 641 of file menu.c.

642{
643}

◆ MENUEX_ParseResource()

static LPCSTR MENUEX_ParseResource ( LPCSTR  res,
HMENU  hMenu 
)
static

Definition at line 455 of file menu.c.

456{
457 WORD resinfo;
458 do
459 {
460 MENUITEMINFOW mii;
461
462 mii.cbSize = sizeof(mii);
464 mii.fType = GET_DWORD(res);
465 res += sizeof(DWORD);
466 mii.fState = GET_DWORD(res);
467 res += sizeof(DWORD);
468 mii.wID = GET_DWORD(res);
469 res += sizeof(DWORD);
470 resinfo = GET_WORD(res);
471 res += sizeof(WORD);
472 /* Align the text on a word boundary. */
473 res += (~((UINT_PTR)res - 1)) & 1;
474 mii.dwTypeData = (LPWSTR)res;
475 mii.cch = strlenW(mii.dwTypeData);
476 res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR);
477 /* Align the following fields on a dword boundary. */
478 res += (~((UINT_PTR)res - 1)) & 3;
479
480 TRACE("Menu item: [%08x,%08x,%04x,%04x,%S]\n",
481 mii.fType, mii.fState, mii.wID, resinfo, mii.dwTypeData);
482
483 if (resinfo & 1) /* Pop-up? */
484 {
485 /* DWORD helpid = GET_DWORD(res); FIXME: use this. */
486 res += sizeof(DWORD);
488 if (!mii.hSubMenu)
489 {
490 ERR("CreatePopupMenu failed\n");
491 return NULL;
492 }
493
494 if (!(res = MENUEX_ParseResource(res, mii.hSubMenu)))
495 {
496 ERR("MENUEX_ParseResource failed\n");
498 return NULL;
499 }
500 mii.fMask |= MIIM_SUBMENU;
501 mii.fType |= MF_POPUP;
502 }
503 else if (!mii.dwTypeData[0] && !(mii.fType & MF_SEPARATOR))
504 {
505 WARN("Converting NULL menu item %04x, type %04x to SEPARATOR\n",
506 mii.wID, mii.fType);
507 mii.fType |= MF_SEPARATOR;
508 }
509 InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii);
510 } while (!(resinfo & MF_END));
511 return res;
512}
#define WARN(fmt,...)
Definition: precomp.h:61
#define DWORD
Definition: nt_native.h:44
#define GET_DWORD(ptr)
Definition: menu.c:63
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

Referenced by LoadMenuIndirectW(), and MENUEX_ParseResource().

◆ MenuInit()

BOOL MenuInit ( VOID  )

Definition at line 635 of file menu.c.

636{
637 return TRUE;
638}

◆ MenuWindowProcA()

LRESULT WINAPI MenuWindowProcA ( HWND  hWnd,
ULONG_PTR  Result,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1666 of file menu.c.

1673{
1674 if ( Msg < WM_USER)
1675 {
1677 }
1679}
struct @1636 Msg[]
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL NTAPI NtUserMessageCall(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
Definition: message.c:2540
#define FNID_MENU
Definition: ntuser.h:861
LRESULT WINAPI PopupMenuWndProcA(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: menu.c:368
#define WM_USER
Definition: winuser.h:1898
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ MenuWindowProcW()

LRESULT WINAPI MenuWindowProcW ( HWND  hWnd,
ULONG_PTR  Result,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1686 of file menu.c.

1693{
1694 if ( Msg < WM_USER)
1695 {
1697 }
1699}
LRESULT WINAPI PopupMenuWndProcW(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: menu.c:297

◆ ModifyMenuA()

BOOL WINAPI ModifyMenuA ( HMENU  hMenu,
UINT  uPosition,
UINT  uFlags,
UINT_PTR  uIDNewItem,
LPCSTR  lpNewItem 
)

Definition at line 1415 of file menu.c.

1421{
1422 MENUITEMINFOW mii;
1424 BOOL res;
1425
1427
1428 MENU_mnu2mnuii( uFlags, uIDNewItem, (LPCWSTR)lpNewItem, &mii, FALSE);
1429
1430 /* copy the text string, it will be one or the other */
1431 if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1432 {
1434 {
1436 return FALSE;
1437 }
1438 mii.dwTypeData = UnicodeString.Buffer;
1439 mii.cch = UnicodeString.Length / sizeof(WCHAR);
1440 }
1441 else
1442 {
1443 TRACE("Handle bitmaps\n");
1444 }
1445 res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), FALSE, &mii, &UnicodeString);
1447 return res;
1448}

◆ ModifyMenuW()

BOOL WINAPI ModifyMenuW ( HMENU  hMenu,
UINT  uPosition,
UINT  uFlags,
UINT_PTR  uIDNewItem,
LPCWSTR  lpNewItem 
)

Definition at line 1455 of file menu.c.

1461{
1462 MENUITEMINFOW mii;
1463 UNICODE_STRING MenuText;
1464 BOOL res;
1465
1466 RtlInitUnicodeString(&MenuText, 0);
1467
1468 MENU_mnu2mnuii( uFlags, uIDNewItem, lpNewItem, &mii, TRUE);
1469
1470 /* copy the text string, it will be one or the other */
1471 if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1472 {
1473 RtlInitUnicodeString(&MenuText, (PWSTR)mii.dwTypeData);
1474 mii.dwTypeData = MenuText.Buffer;
1475 mii.cch = MenuText.Length / sizeof(WCHAR);
1476 }
1477 else
1478 {
1479 TRACE("Handle bitmaps\n");
1480 }
1481 res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), FALSE, &mii, &MenuText);
1482 return res;
1483}

◆ PopupMenuWndProcA()

LRESULT WINAPI PopupMenuWndProcA ( HWND  Wnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 368 of file menu.c.

369{
370 PWND pWnd;
371
372 pWnd = ValidateHwnd(Wnd);
373 if (pWnd && !pWnd->fnid && Message != WM_NCCREATE)
374 {
375 return DefWindowProcA(Wnd, Message, wParam, lParam);
376 }
377 TRACE("YES! hwnd=%x msg=0x%04x wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
378
379 switch(Message)
380 {
381 case WM_NCCREATE:
382 case WM_CREATE:
383 case WM_MOUSEACTIVATE:
384 case WM_PAINT:
385 case WM_PRINTCLIENT:
386 case WM_ERASEBKGND:
387 case WM_DESTROY:
388 case WM_NCDESTROY:
389 case WM_SHOWWINDOW:
390 case MM_SETMENUHANDLE:
391 case MM_GETMENUHANDLE:
392 case MN_SETHMENU:
393 case MN_GETHMENU:
394 return PopupMenuWndProcW(Wnd, Message, wParam, lParam);
395
396 default:
397 return DefWindowProcA(Wnd, Message, wParam, lParam);
398 }
399 return 0;
400}
static const WCHAR Message[]
Definition: register.c:74
#define WM_PRINTCLIENT
Definition: richedit.h:70
DWORD fnid
Definition: ntuser.h:709
#define MN_SETHMENU
Definition: undocuser.h:53
#define MM_SETMENUHANDLE
Definition: menu.c:30
#define MM_GETMENUHANDLE
Definition: menu.c:31
#define WM_PAINT
Definition: winuser.h:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1611
#define MN_GETHMENU
Definition: winuser.h:1776
#define WM_NCCREATE
Definition: winuser.h:1686
#define WM_SHOWWINDOW
Definition: winuser.h:1631
#define WM_MOUSEACTIVATE
Definition: winuser.h:1640
#define WM_NCDESTROY
Definition: winuser.h:1687
#define WM_DESTROY
Definition: winuser.h:1612

Referenced by MenuWindowProcA(), and RegisterClientPFN().

◆ PopupMenuWndProcW()

LRESULT WINAPI PopupMenuWndProcW ( HWND  Wnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 297 of file menu.c.

298{
299 LRESULT lResult;
300 PWND pWnd;
301
302 TRACE("PMWPW : hwnd=%x msg=0x%04x wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
303
304 pWnd = ValidateHwnd(Wnd);
305 if (pWnd)
306 {
307 if (!pWnd->fnid)
308 {
309 if (Message != WM_NCCREATE)
310 {
311 return DefWindowProcW(Wnd, Message, wParam, lParam);
312 }
313 }
314 else
315 {
316 if (pWnd->fnid != FNID_MENU)
317 {
318 ERR("Wrong window class for Menu!\n");
319 return 0;
320 }
321 }
322 }
323
324 switch(Message)
325 {
326 case WM_DESTROY:
327 case WM_NCDESTROY:
328 case WM_NCCREATE:
329 case WM_CREATE:
330 case MM_SETMENUHANDLE:
331 case MM_GETMENUHANDLE:
332 case MN_SETHMENU:
333 case MN_GETHMENU:
334 case WM_PAINT:
335 case WM_PRINTCLIENT:
336 {
337 TRACE("Menu Class ProcW\n");
339 return lResult;
340 }
341 case WM_MOUSEACTIVATE: /* We don't want to be activated */
342 return MA_NOACTIVATE;
343
344 case WM_ERASEBKGND:
345 return 1;
346
347 case WM_SHOWWINDOW: // Not sure what this does....
348 if (0 != wParam)
349 {
350 if (0 == GetWindowLongPtrW(Wnd, 0))
351 {
352 OutputDebugStringA("no menu to display\n");
353 }
354 }
355 else
356 {
357 //SetWindowLongPtrW(Wnd, 0, 0);
358 }
359 break;
360
361 default:
362 return DefWindowProcW(Wnd, Message, wParam, lParam);
363 }
364
365 return 0;
366}
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18
LONG_PTR LRESULT
Definition: windef.h:209
#define GetWindowLongPtrW
Definition: winuser.h:4832
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MA_NOACTIVATE
Definition: winuser.h:2506

Referenced by MenuWindowProcW(), PopupMenuWndProcA(), and RegisterClientPFN().

◆ SetMenu()

BOOL WINAPI SetMenu ( HWND  hWnd,
HMENU  hMenu 
)

Definition at line 1489 of file menu.c.

1491{
1492 return NtUserSetMenu(hWnd, hMenu, TRUE);
1493}
BOOL NTAPI NtUserSetMenu(HWND hWnd, HMENU hMenu, BOOL bRepaint)
Definition: menu.c:6417

◆ SetMenuInfo()

BOOL WINAPI SetMenuInfo ( HMENU  hmenu,
LPCMENUINFO  lpcmi 
)

Definition at line 1500 of file menu.c.

1503{
1504 MENUINFO mi;
1505 BOOL res = FALSE;
1506
1507 if (!lpcmi || (lpcmi->cbSize != sizeof(MENUINFO)))
1508 {
1510 return res;
1511 }
1512
1513 memcpy(&mi, lpcmi, sizeof(MENUINFO));
1515}
BOOL NTAPI NtUserThunkedMenuInfo(HMENU hMenu, LPCMENUINFO lpcmi)
Definition: menu.c:6535
static MONITORINFO mi
Definition: win.c:7338
MENUINFO CONST * LPCMENUINFO
Definition: winuser.h:3747

◆ SetMenuItemBitmaps()

BOOL WINAPI SetMenuItemBitmaps ( HMENU  hMenu,
UINT  uPosition,
UINT  uFlags,
HBITMAP  hBitmapUnchecked,
HBITMAP  hBitmapChecked 
)

Definition at line 1522 of file menu.c.

1528{
1529 MENUITEMINFOW uItem;
1530 memset ( &uItem, 0, sizeof(uItem) );
1531 uItem.cbSize = sizeof(MENUITEMINFOW);
1532 uItem.fMask = MIIM_CHECKMARKS;
1533 uItem.hbmpUnchecked = hBitmapUnchecked;
1534 uItem.hbmpChecked = hBitmapChecked;
1535 return SetMenuItemInfoW(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), &uItem);
1536}
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

◆ SetMenuItemInfoA()

BOOL WINAPI SetMenuItemInfoA ( HMENU  hmenu,
UINT  item,
BOOL  bypos,
LPCMENUITEMINFOA  lpmii 
)

Definition at line 1543 of file menu.c.

1548{
1549 MENUITEMINFOW mii;
1551 BOOL Ret;
1552
1553 TRACE("hmenu %p, item %u, by pos %d, info %p\n", hmenu, item, bypos, lpmii);
1554
1556
1557 if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &mii )) return FALSE;
1558/*
1559 * MIIM_STRING == good
1560 * MIIM_TYPE & MFT_STRING == good
1561 * MIIM_STRING & MFT_STRING == good
1562 * MIIM_STRING & MFT_OWNERDRAW == good
1563 */
1564 if (((mii.fMask & MIIM_STRING) ||
1565 ((mii.fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(mii.fType) == MF_STRING)))
1566 && mii.dwTypeData && !(GdiValidateHandle((HGDIOBJ)mii.dwTypeData)) )
1567 {
1568 /* cch is ignored when the content of a menu item is set by calling SetMenuItemInfo. */
1570 {
1572 return FALSE;
1573 }
1574 mii.dwTypeData = UnicodeString.Buffer;
1575 mii.cch = UnicodeString.Length / sizeof(WCHAR);
1576 }
1577 else
1578 {
1579 UnicodeString.Buffer = NULL;
1580 }
1581 Ret = NtUserThunkedMenuItemInfo(hmenu, item, bypos, FALSE, &mii, &UnicodeString);
1583 return Ret;
1584}

◆ SetMenuItemInfoW()

BOOL WINAPI SetMenuItemInfoW ( HMENU  hMenu,
UINT  uItem,
BOOL  fByPosition,
LPCMENUITEMINFOW  lpmii 
)

Definition at line 1591 of file menu.c.

1596{
1597 MENUITEMINFOW MenuItemInfoW;
1599 BOOL Ret;
1600
1601 TRACE("hmenu %p, item %u, by pos %d, info %p\n", hMenu, uItem, fByPosition, lpmii);
1602
1604
1605 if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &MenuItemInfoW )) return FALSE;
1606
1607 if (((MenuItemInfoW.fMask & MIIM_STRING) ||
1608 ((MenuItemInfoW.fMask & MIIM_TYPE) &&
1609 (MENU_ITEM_TYPE(MenuItemInfoW.fType) == MF_STRING)))
1610 && MenuItemInfoW.dwTypeData && !(GdiValidateHandle((HGDIOBJ)MenuItemInfoW.dwTypeData)) )
1611 {
1613 MenuItemInfoW.cch = strlenW(MenuItemInfoW.dwTypeData);
1614 }
1615 Ret = NtUserThunkedMenuItemInfo(hMenu, uItem, fByPosition, FALSE, &MenuItemInfoW, &UnicodeString);
1616
1617 return Ret;
1618}
const uint16_t * PCWSTR
Definition: typedefs.h:57

◆ SetSystemMenu()

BOOL WINAPI SetSystemMenu ( HWND  hwnd,
HMENU  hMenu 
)

Definition at line 1625 of file menu.c.

1628{
1629 if(!hwnd)
1630 {
1632 return FALSE;
1633 }
1634 if(!hMenu)
1635 {
1637 return FALSE;
1638 }
1639 return NtUserSetSystemMenu(hwnd, hMenu);
1640}
BOOL NTAPI NtUserSetSystemMenu(HWND hWnd, HMENU hMenu)
Definition: menu.c:5711
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881

◆ TrackPopupMenu()

BOOL WINAPI TrackPopupMenu ( HMENU  Menu,
UINT  Flags,
int  x,
int  y,
int  Reserved,
HWND  Wnd,
CONST RECT Rect 
)

Definition at line 1644 of file menu.c.

1652{
1653 return NtUserTrackPopupMenuEx( Menu,
1654 Flags,
1655 x,
1656 y,
1657 Wnd,
1658 NULL); // LPTPMPARAMS is null
1659}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL NTAPI NtUserTrackPopupMenuEx(HMENU hmenu, UINT fuFlags, int x, int y, HWND hwnd, LPTPMPARAMS lptpm)
Definition: menu.c:6624
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

◆ User32CallLoadMenuFromKernel()

NTSTATUS WINAPI User32CallLoadMenuFromKernel ( PVOID  Arguments,
ULONG  ArgumentLength 
)

Definition at line 657 of file menu.c.

658{
661
662 Common = (PLOADMENU_CALLBACK_ARGUMENTS) Arguments;
663
664 Result = (LRESULT)LoadMenuW(Common->hModule, Common->InterSource ? MAKEINTRESOURCEW(Common->InterSource) : (LPCWSTR)&Common->MenuName);
665
667}
NTSYSAPI NTSTATUS NTAPI ZwCallbackReturn(_In_ PVOID Result, _In_ ULONG ResultLength, _In_ NTSTATUS Status)
#define LRESULT
Definition: ole.h:14
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _LOADMENU_CALLBACK_ARGUMENTS * PLOADMENU_CALLBACK_ARGUMENTS
HMENU WINAPI LoadMenuW(HINSTANCE hInstance, LPCWSTR lpMenuName)
Definition: menu.c:1399
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ User32LoadSysMenuTemplateForKernel()

NTSTATUS WINAPI User32LoadSysMenuTemplateForKernel ( PVOID  Arguments,
ULONG  ArgumentLength 
)

Definition at line 647 of file menu.c.

648{
649 LRESULT Result = 0;
650
651 // Use this for Menu Ole!!
652
653 return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS));
654}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( menu  )

Variable Documentation

◆ POPUPMENU_builtin_class

const struct builtin_class_descr POPUPMENU_builtin_class
Initial value:
=
{
NULL,
sizeof(MENUINFO *),
(HBRUSH)(COLOR_MENU + 1)
}
#define WC_MENU
Definition: undocuser.h:9
#define COLOR_MENU
Definition: winuser.h:920
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
#define CS_SAVEBITS
Definition: winuser.h:657

Definition at line 48 of file menu.c.