ReactOS  0.4.14-dev-98-gb0d4763
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 IS_SYSTEM_MENU(MenuInfo)   (0 == ((MenuInfo)->fFlags & MNF_POPUP) && 0 != ((MenuInfo)->fFlags & MNF_SYSMENU))
 
#define IS_SYSTEM_POPUP(MenuInfo)   (0 != ((MenuInfo)->fFlags & MNF_POPUP) && 0 != ((MenuInfo)->fFlags & MNF_SYSMENU))
 
#define IS_BITMAP_ITEM(flags)   (MF_BITMAP == MENU_ITEM_TYPE(flags))
 
#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 71 of file menu.c.

◆ GET_WORD

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

Definition at line 68 of file menu.c.

◆ IS_BITMAP_ITEM

#define IS_BITMAP_ITEM (   flags)    (MF_BITMAP == MENU_ITEM_TYPE(flags))

Definition at line 51 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.

◆ IS_SYSTEM_MENU

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

Definition at line 45 of file menu.c.

◆ IS_SYSTEM_POPUP

#define IS_SYSTEM_POPUP (   MenuInfo)    (0 != ((MenuInfo)->fFlags & MNF_POPUP) && 0 != ((MenuInfo)->fFlags & MNF_SYSMENU))

Definition at line 48 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_MENUBARBREAK | MFT_MENUBREAK | MFT_RADIOCHECK | \
MFT_RIGHTORDER | MFT_RIGHTJUSTIFY /* same as MF_HELP */ )
#define MFT_RIGHTJUSTIFY
Definition: winuser.h:738
#define MFT_STRING
Definition: winuser.h:741
#define MFT_RADIOCHECK
Definition: winuser.h:737
#define MFT_BITMAP
Definition: winuser.h:733
#define MFT_SEPARATOR
Definition: winuser.h:739
#define MFT_MENUBREAK
Definition: winuser.h:735
#define MFT_OWNERDRAW
Definition: winuser.h:736

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

688 {
689  MENUITEMINFOW mii;
691  BOOL res;
692 
694 
695  MENU_mnu2mnuii( uFlags, uIDNewItem, (LPCWSTR)lpNewItem, &mii, FALSE);
696 
697  /* copy the text string, it will be one or the other */
698  if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
699  {
701  {
703  return FALSE;
704  }
705  mii.dwTypeData = UnicodeString.Buffer;
706  mii.cch = UnicodeString.Length / sizeof(WCHAR);
707  }
708  else
709  {
710  TRACE("AMA Handle bitmaps\n");
711  }
713  res = NtUserThunkedMenuItemInfo(hMenu, -1, TRUE, TRUE, &mii, &UnicodeString);
715  return res;
716 }
#define TRUE
Definition: types.h:120
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static void MENU_mnu2mnuii(UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
Definition: menu.c:529
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LPWSTR dwTypeData
Definition: winuser.h:3243
UINT uFlags
Definition: api.c:60
char * LPSTR
Definition: xmlstorage.h:182
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
#define MIIM_STRING
Definition: winuser.h:722
GLuint res
Definition: glext.h:9613
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by ChangeMenuA(), create_menu_from_data(), menu_fill_in_init(), test_AppendMenu(), test_getmenubarinfo(), test_menu_cancelmode(), test_menu_circref(), test_menu_flags(), test_menu_hilitemenuitem(), test_menu_input(), test_menu_maxdepth(), test_menu_ownerdraw(), test_menu_resource_layout(), test_menu_search_bycommand(), test_menu_trackagain(), and test_menu_trackpopupmenu().

◆ AppendMenuW()

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

Definition at line 722 of file menu.c.

726 {
727  MENUITEMINFOW mii;
728  UNICODE_STRING MenuText;
729  BOOL res;
730 
731  RtlInitUnicodeString(&MenuText, 0);
732 
733  MENU_mnu2mnuii( uFlags, uIDNewItem, lpNewItem, &mii, TRUE);
734 
735  /* copy the text string, it will be one or the other */
736  if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
737  {
738  RtlInitUnicodeString(&MenuText, (PWSTR)mii.dwTypeData);
739  mii.dwTypeData = MenuText.Buffer;
740  mii.cch = MenuText.Length / sizeof(WCHAR);
741  }
742  res = NtUserThunkedMenuItemInfo(hMenu, -1, TRUE, TRUE, &mii, &MenuText);
743  return res;
744 }
#define TRUE
Definition: types.h:120
static void MENU_mnu2mnuii(UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
Definition: menu.c:529
uint16_t * PWSTR
Definition: typedefs.h:54
LPWSTR dwTypeData
Definition: winuser.h:3243
UINT uFlags
Definition: api.c:60
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MIIM_STRING
Definition: winuser.h:722
GLuint res
Definition: glext.h:9613
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by ChangeMenuW(), and MENU_ParseResource().

◆ ChangeMenuA()

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

Definition at line 1752 of file menu.c.

1758 {
1759  /*
1760  FIXME: Word passes the item id in 'cmd' and 0 or 0xffff as cmdInsert
1761  for MF_DELETE. We should check the parameters for all others
1762  MF_* actions also (anybody got a doc on ChangeMenu?).
1763  */
1764 
1766  {
1767  case MF_APPEND :
1768  return AppendMenuA(hMenu, flags &~ MF_APPEND, cmdInsert, lpszNewItem);
1769 
1770  case MF_DELETE :
1771  return DeleteMenu(hMenu, cmd, flags &~ MF_DELETE);
1772 
1773  case MF_CHANGE :
1774  return ModifyMenuA(hMenu, cmd, flags &~ MF_CHANGE, cmdInsert, lpszNewItem);
1775 
1776  case MF_REMOVE :
1777  return RemoveMenu(hMenu, flags & MF_BYPOSITION ? cmd : cmdInsert,
1778  flags &~ MF_REMOVE);
1779 
1780  default : /* MF_INSERT */
1781  return InsertMenuA(hMenu, cmd, flags, cmdInsert, lpszNewItem);
1782  };
1783 }
BOOL WINAPI InsertMenuA(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:1179
Definition: ftp_var.h:139
BOOL WINAPI ModifyMenuA(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:1423
#define MF_CHANGE
Definition: winuser.h:147
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
#define MF_REMOVE
Definition: winuser.h:150
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_DELETE
Definition: winuser.h:149
GLbitfield flags
Definition: glext.h:7161
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_APPEND
Definition: winuser.h:148
#define MF_INSERT
Definition: winuser.h:146

◆ ChangeMenuW()

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

Definition at line 1714 of file menu.c.

1720 {
1721  /*
1722  FIXME: Word passes the item id in 'cmd' and 0 or 0xffff as cmdInsert
1723  for MF_DELETE. We should check the parameters for all others
1724  MF_* actions also (anybody got a doc on ChangeMenu?).
1725  */
1726 
1728  {
1729  case MF_APPEND :
1730  return AppendMenuW(hMenu, flags &~ MF_APPEND, cmdInsert, lpszNewItem);
1731 
1732  case MF_DELETE :
1733  return DeleteMenu(hMenu, cmd, flags &~ MF_DELETE);
1734 
1735  case MF_CHANGE :
1736  return ModifyMenuW(hMenu, cmd, flags &~ MF_CHANGE, cmdInsert, lpszNewItem);
1737 
1738  case MF_REMOVE :
1739  return RemoveMenu(hMenu, flags & MF_BYPOSITION ? cmd : cmdInsert,
1740  flags &~ MF_REMOVE);
1741 
1742  default : /* MF_INSERT */
1743  return InsertMenuW(hMenu, cmd, flags, cmdInsert, lpszNewItem);
1744  };
1745 }
Definition: ftp_var.h:139
BOOL WINAPI ModifyMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:1463
#define MF_CHANGE
Definition: winuser.h:147
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:1300
#define MF_REMOVE
Definition: winuser.h:150
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_DELETE
Definition: winuser.h:149
GLbitfield flags
Definition: glext.h:7161
BOOL WINAPI AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:722
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_APPEND
Definition: winuser.h:148
#define MF_INSERT
Definition: winuser.h:146

◆ CheckMenuItem()

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

Definition at line 750 of file menu.c.

753 {
754  PITEM item;
755  DWORD Ret;
756  UINT uID = uIDCheckItem;
757 
759  return -1;
760 
761  if (!(item = MENU_FindItem( &hmenu, &uID, uCheck ))) return -1;
762 
763  Ret = item->fState & MFS_CHECKED;
764  if ( Ret == (uCheck & MFS_CHECKED)) return Ret; // Already Checked...
765 
766  return NtUserCheckMenuItem(hmenu, uIDCheckItem, uCheck);
767 }
static HMENU hmenu
Definition: win.c:66
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
DWORD APIENTRY NtUserCheckMenuItem(HMENU hMenu, UINT uIDCheckItem, UINT uCheck)
Definition: menu.c:5581
unsigned long DWORD
Definition: ntddk_ex.h:95
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:717
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
#define MFS_CHECKED
Definition: winuser.h:742

Referenced by test_system_menu().

◆ CheckMenuRadioItem()

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

Definition at line 773 of file menu.c.

778 {
779  BOOL done = FALSE;
780  UINT i;
781  PITEM mi_first = NULL, mi_check;
782  HMENU m_first, m_check;
783  MENUITEMINFOW mii;
784  mii.cbSize = sizeof( mii);
785 
786  for (i = first; i <= last; i++)
787  {
788  UINT pos = i;
789 
790  if (!mi_first)
791  {
792  m_first = hMenu;
793  mi_first = MENU_FindItem(&m_first, &pos, bypos);
794  if (!mi_first) continue;
795  mi_check = mi_first;
796  m_check = m_first;
797  }
798  else
799  {
800  m_check = hMenu;
801  mi_check = MENU_FindItem(&m_check, &pos, bypos);
802  if (!mi_check) continue;
803  }
804 
805  if (m_first != m_check) continue;
806  if (mi_check->fType == MFT_SEPARATOR) continue;
807 
808  if (i == check)
809  {
810  if (!(mi_check->fType & MFT_RADIOCHECK) || !(mi_check->fState & MFS_CHECKED))
811  {
812  mii.fMask = MIIM_FTYPE | MIIM_STATE;
813  mii.fType = (mi_check->fType & MENUITEMINFO_TYPE_MASK) | MFT_RADIOCHECK;
814  mii.fState = (mi_check->fState & MII_STATE_MASK) | MFS_CHECKED;
815  NtUserThunkedMenuItemInfo(m_check, i, bypos, FALSE, &mii, NULL);
816  }
817  done = TRUE;
818  }
819  else
820  {
821  /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
822  if (mi_check->fState & MFS_CHECKED)
823  {
824  mii.fMask = MIIM_STATE;
825  mii.fState = (mi_check->fState & MII_STATE_MASK) & ~MFS_CHECKED;
826  NtUserThunkedMenuItemInfo(m_check, i, bypos, FALSE, &mii, NULL);
827  }
828  }
829  }
830  return done;
831 }
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
POINT last
Definition: font.c:46
const GLint * first
Definition: glext.h:5794
#define MFT_RADIOCHECK
Definition: winuser.h:737
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:28
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MII_STATE_MASK
Definition: menu.c:39
smooth NULL
Definition: ftsmooth.c:416
void check(CONTEXT *pContext)
Definition: NtContinue.c:61
#define MFT_SEPARATOR
Definition: winuser.h:739
unsigned int UINT
Definition: ndis.h:50
#define MFS_CHECKED
Definition: winuser.h:742
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by test_CheckMenuRadioItem().

◆ CreateMenu()

◆ CreatePopupMenu()

HMENU WINAPI CreatePopupMenu ( VOID  )

Definition at line 846 of file menu.c.

847 {
848  return NtUserxCreatePopupMenu();
849 }
EXTINLINE HMENU NtUserxCreatePopupMenu(VOID)
Definition: ntwrapper.h:556

Referenced by CBandSiteBase::_OnContextMenu(), _ShowContextMenu(), _ShowContextMenuR(), CMenuBand::_TrackContextMenu(), add_favs_to_menu(), AppendMenuItems(), BuildLeftPopupMenu(), CDrivesFolder::CallBack(), CDesktopFolder::CallBack(), CFSFolder::CallBack(), ConWndProc(), DesktopShellView::DoDesktopContextMenu(), CDefView::Exec(), FileMenu_Create(), CDefView::FillFileMenu(), FM_InitMenuPopup(), GuiConsoleAppendMenuItems(), GuiConsoleWndProc(), handle_context_menu(), IFileDialogCustomize_fnAddMenu(), IFileDialogCustomize_fnEnableOpenDropDown(), CFolderItemVerbs::Init(), MENU_ParseResource(), MENUEX_ParseResource(), MONTHCAL_LButtonDown(), MONTHCAL_RButtonUp(), msi_seltree_popup_menu(), OleUIAddVerbMenuW(), CDeviceManager::OnCommand(), CDeviceView::OnContextMenu(), CExplorerBand::OnContextMenu(), CDefView::OnContextMenu(), CDefView::OnExplorerCommand(), CInternetToolbar::OnMenuDropDown(), CISFBand::OnWinEvent(), CDefView::OpenSelectedItems(), COpenWithMenu::QueryContextMenu(), Shell_MergeMenus(), ShellFolderContextMenu(), SHInvokeCommand(), ShowContextMenu(), ShowPowerSchemesPopupMenu(), START_TEST(), TaskManager_OnTabWndSelChange(), test_AppendMenu(), test_capture_4(), test_contextmenu(), test_CShellMenu_params(), test_emptypopup(), 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(), and CTrayWindow::TrackCtxMenu().

◆ DrawMenuBar()

BOOL WINAPI DrawMenuBar ( HWND  hWnd)

Definition at line 855 of file menu.c.

856 {
857  return NtUserxDrawMenuBar(hWnd);
858 }
HWND hWnd
Definition: settings.c:17
EXTINLINE BOOL NtUserxDrawMenuBar(HWND hWnd)
Definition: ntwrapper.h:778

Referenced by test_mbs_help(), and test_menu_locked_by_window().

◆ EnableMenuItem()

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

Definition at line 864 of file menu.c.

867 {
868  return NtUserEnableMenuItem(hMenu, uIDEnableItem, uEnable);
869 }
UINT APIENTRY NtUserEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, UINT uEnable)
Definition: menu.c:5856

Referenced by test_system_menu().

◆ 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
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define GDI_ENTRY_BASETYPE_MASK
Definition: ntgdihdl.h:34
PGDI_TABLE_ENTRY GdiHandleTable
Definition: misc.c:33
smooth NULL
Definition: ftsmooth.c:416
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
HANDLE CurrentProcessId
Definition: misc.c:35
PVOID HANDLE
Definition: typedefs.h:71
Definition: gdi.h:1
#define GDI_ENTRY_UPPER_SHIFT
Definition: ntgdihdl.h:35
#define GDI_HANDLE_TYPE_MASK
Definition: gdi.h:17
base of all file and directory entries
Definition: entries.h:82

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

◆ GetMenu()

HMENU WINAPI GetMenu ( HWND  hWnd)

Definition at line 875 of file menu.c.

876 {
877  PWND Wnd = ValidateHwnd(hWnd);
878 
879  if (!Wnd)
880  return NULL;
881 
882  return UlongToHandle(Wnd->IDMenu);
883 }
HWND hWnd
Definition: settings.c:17
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR IDMenu
Definition: ntuser.h:695
#define UlongToHandle(ul)
Definition: basetsd.h:97
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
Definition: ntuser.h:657

Referenced by test_menu_locked_by_window(), and WndProc().

◆ GetMenuCheckMarkDimensions()

LONG WINAPI GetMenuCheckMarkDimensions ( VOID  )

Definition at line 889 of file menu.c.

890 {
893 }
#define SM_CXMENUCHECK
Definition: winuser.h:1021
#define SM_CYMENUCHECK
Definition: winuser.h:1022
#define MAKELONG(a, b)
Definition: typedefs.h:248
int WINAPI GetSystemMetrics(_In_ int)

◆ GetMenuContextHelpId()

DWORD WINAPI GetMenuContextHelpId ( HMENU  hmenu)

Definition at line 900 of file menu.c.

901 {
902  PMENU pMenu;
903  if ((pMenu = ValidateHandle(hmenu, TYPE_MENU)))
904  return pMenu->dwContextHelpId;
905  return 0;
906 }
static HMENU hmenu
Definition: win.c:66
DWORD dwContextHelpId
Definition: ntuser.h:396
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:717

◆ GetMenuDefaultItem()

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

Definition at line 912 of file menu.c.

915 {
916  PMENU pMenu;
917  DWORD gismc = 0;
918  if (!(pMenu = ValidateHandle(hMenu, TYPE_MENU)))
919  return (UINT)-1;
920 
921  return IntGetMenuDefaultItem( pMenu, (BOOL)fByPos, gmdiFlags, &gismc);
922 }
unsigned int BOOL
Definition: ntddk_ex.h:94
UINT FASTCALL IntGetMenuDefaultItem(PMENU MenuObject, UINT fByPos, UINT gmdiFlags, DWORD *gismc)
Definition: menu.c:1315
unsigned long DWORD
Definition: ntddk_ex.h:95
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:717
unsigned int UINT
Definition: ndis.h:50

◆ GetMenuInfo()

BOOL WINAPI GetMenuInfo ( HMENU  hmenu,
LPMENUINFO  lpcmi 
)

Definition at line 928 of file menu.c.

930 {
931  PMENU pMenu;
932 
933  if (!lpcmi || (lpcmi->cbSize != sizeof(MENUINFO)))
934  {
936  return FALSE;
937  }
938 
939  if (!(pMenu = ValidateHandle(hmenu, TYPE_MENU)))
940  return FALSE;
941 
942  if (lpcmi->fMask & MIM_BACKGROUND)
943  lpcmi->hbrBack = pMenu->hbrBack;
944 
945  if (lpcmi->fMask & MIM_HELPID)
946  lpcmi->dwContextHelpID = pMenu->dwContextHelpId;
947 
948  if (lpcmi->fMask & MIM_MAXHEIGHT)
949  lpcmi->cyMax = pMenu->cyMax;
950 
951  if (lpcmi->fMask & MIM_MENUDATA)
952  lpcmi->dwMenuData = pMenu->dwMenuData;
953 
954  if (lpcmi->fMask & MIM_STYLE)
955  lpcmi->dwStyle = pMenu->fFlags & MNS_STYLE_MASK;
956 
957  return TRUE;
958 }
DWORD_PTR dwMenuData
Definition: ntuser.h:398
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
ULONG_PTR dwMenuData
Definition: winuser.h:3715
HBRUSH hbrBack
Definition: ntuser.h:399
static HMENU hmenu
Definition: win.c:66
DWORD dwStyle
Definition: winuser.h:3711
DWORD dwContextHelpID
Definition: winuser.h:3714
UINT cyMax
Definition: winuser.h:3712
HBRUSH hbrBack
Definition: winuser.h:3713
DWORD dwContextHelpId
Definition: ntuser.h:396
ULONG cyMax
Definition: ntuser.h:397
#define SetLastError(x)
Definition: compat.h:409
DWORD fMask
Definition: winuser.h:3710
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:717
#define MNS_STYLE_MASK
Definition: menu.c:26
DWORD cbSize
Definition: winuser.h:3709
ULONG fFlags
Definition: ntuser.h:386

Referenced by init_function_pointers().

◆ GetMenuItemCount()

int WINAPI GetMenuItemCount ( HMENU  hmenu)

Definition at line 964 of file menu.c.

965 {
966  PMENU pMenu;
967  if ((pMenu = ValidateHandle(hmenu, TYPE_MENU)))
968  return pMenu->cItems;
969  return -1;
970 }
static HMENU hmenu
Definition: win.c:66
UINT cItems
Definition: ntuser.h:389
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:717

Referenced by check_menu_items(), compare_menu_data(), and test_menu_resource_layout().

◆ GetMenuItemID()

UINT WINAPI GetMenuItemID ( HMENU  hMenu,
int  nPos 
)

Definition at line 976 of file menu.c.

978 {
979  ITEM * lpmi;
980  if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return -1;
981  if (lpmi->spSubMenu) return -1;
982  return lpmi->wID;
983 }
Definition: fontsub.cpp:35
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
#define MF_BYPOSITION
Definition: winuser.h:203
unsigned int UINT
Definition: ndis.h:50

Referenced by test_menu_search_bycommand().

◆ GetMenuItemInfo_common()

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

Definition at line 175 of file menu.c.

180 {
181  ITEM *pItem = MENU_FindItem (&hmenu, &item, bypos ? MF_BYPOSITION : 0);
182 
183  //debug_print_menuitem("GetMenuItemInfo_common: ", pItem, "");
184 
185  if (!pItem)
186  {
188  return FALSE;
189  }
190 
191  if( lpmii->fMask & MIIM_TYPE)
192  {
193  if( lpmii->fMask & ( MIIM_STRING | MIIM_FTYPE | MIIM_BITMAP))
194  {
195  ERR("invalid combination of fMask bits used\n");
196  /* this does not happen on Win9x/ME */
198  return FALSE;
199  }
200  lpmii->fType = pItem->fType & MENUITEMINFO_TYPE_MASK;
201  if (pItem->hbmp && !IS_MAGIC_BITMAP(pItem->hbmp))
202  lpmii->fType |= MFT_BITMAP;
203  lpmii->hbmpItem = pItem->hbmp; /* not on Win9x/ME */
204  if( lpmii->fType & MFT_BITMAP)
205  {
206  lpmii->dwTypeData = (LPWSTR) pItem->hbmp;
207  lpmii->cch = 0;
208  }
209  else if( lpmii->fType & (MFT_OWNERDRAW | MFT_SEPARATOR))
210  {
211  /* this does not happen on Win9x/ME */
212  lpmii->dwTypeData = 0;
213  lpmii->cch = 0;
214  }
215  }
216 
217  /* copy the text string */
218  if ((lpmii->fMask & (MIIM_TYPE|MIIM_STRING)))
219  {
220  if( !pItem->Xlpstr )
221  { // Very strange this fixes a wine test with a crash.
222  if(lpmii->dwTypeData && lpmii->cch && !(GdiValidateHandle((HGDIOBJ)lpmii->dwTypeData)) )
223  {
224  if( unicode)
225  *((WCHAR *)lpmii->dwTypeData) = 0;
226  else
227  *((CHAR *)lpmii->dwTypeData) = 0;
228  }
229  lpmii->cch = 0;
230  }
231  else
232  {
233  int len;
234  LPWSTR text = DesktopPtrToUser(pItem->Xlpstr);
235  if (unicode)
236  {
237  len = strlenW(text);
238  if(lpmii->dwTypeData && lpmii->cch)
239  lstrcpynW(lpmii->dwTypeData, text, lpmii->cch);
240  }
241  else
242  {
243  len = WideCharToMultiByte( CP_ACP, 0, text, -1, NULL, 0, NULL, NULL ) - 1;
244  if(lpmii->dwTypeData && lpmii->cch)
245  if (!WideCharToMultiByte( CP_ACP, 0, text, -1,
246  (LPSTR)lpmii->dwTypeData, lpmii->cch, NULL, NULL ))
247  ((LPSTR)lpmii->dwTypeData)[lpmii->cch - 1] = 0;
248  }
249  /* if we've copied a substring we return its length */
250  if(lpmii->dwTypeData && lpmii->cch)
251  if (lpmii->cch <= len + 1)
252  lpmii->cch--;
253  else
254  lpmii->cch = len;
255  else
256  {
257  /* return length of string */
258  /* not on Win9x/ME if fType & MFT_BITMAP */
259  lpmii->cch = len;
260  }
261  }
262  }
263 
264  if (lpmii->fMask & MIIM_FTYPE)
265  lpmii->fType = pItem->fType & MENUITEMINFO_TYPE_MASK;
266 
267  if (lpmii->fMask & MIIM_BITMAP)
268  lpmii->hbmpItem = pItem->hbmp;
269 
270  if (lpmii->fMask & MIIM_STATE)
271  lpmii->fState = pItem->fState & MENUITEMINFO_STATE_MASK;
272 
273  if (lpmii->fMask & MIIM_ID)
274  lpmii->wID = pItem->wID;
275 
276  if (lpmii->fMask & MIIM_SUBMENU && pItem->spSubMenu )
277  {
278  PMENU pSubMenu = DesktopPtrToUser(pItem->spSubMenu);
279  HMENU hSubMenu = UserHMGetHandle(pSubMenu);
280  lpmii->hSubMenu = hSubMenu;
281  }
282  else
283  {
284  /* hSubMenu is always cleared
285  * (not on Win9x/ME ) */
286  lpmii->hSubMenu = 0;
287  }
288 
289  if (lpmii->fMask & MIIM_CHECKMARKS)
290  {
291  lpmii->hbmpChecked = pItem->hbmpChecked;
292  lpmii->hbmpUnchecked = pItem->hbmpUnchecked;
293  }
294  if (lpmii->fMask & MIIM_DATA)
295  lpmii->dwItemData = pItem->dwItemData;
296 
297  return TRUE;
298 }
Definition: fontsub.cpp:35
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
HBITMAP hbmpChecked
Definition: winuser.h:3240
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WideCharToMultiByte
Definition: compat.h:101
static HMENU hmenu
Definition: win.c:66
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
LPWSTR dwTypeData
Definition: winuser.h:3243
#define MFT_BITMAP
Definition: winuser.h:733
char * LPSTR
Definition: xmlstorage.h:182
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:28
#define MIIM_BITMAP
Definition: winuser.h:723
#define lstrcpynW
Definition: compat.h:397
#define MIIM_SUBMENU
Definition: winuser.h:718
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
#define MIIM_STATE
Definition: winuser.h:716
#define MF_BYPOSITION
Definition: winuser.h:203
smooth NULL
Definition: ftsmooth.c:416
#define MIIM_ID
Definition: winuser.h:717
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
#define MFT_SEPARATOR
Definition: winuser.h:739
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937
#define MIIM_TYPE
Definition: winuser.h:720
GLenum GLsizei len
Definition: glext.h:6722
#define MIIM_CHECKMARKS
Definition: winuser.h:719
#define ERR(fmt,...)
Definition: debug.h:109
#define MIIM_STRING
Definition: winuser.h:722
BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj)
Definition: misc.c:712
static ATOM item
Definition: dde.c:856
#define MENUITEMINFO_STATE_MASK
Definition: menu.c:37
#define IS_MAGIC_BITMAP(id)
Definition: menu.c:43
LPCSTR text
Definition: menu.c:130
HBITMAP hbmpUnchecked
Definition: winuser.h:3241
#define MFT_OWNERDRAW
Definition: winuser.h:736
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define MIIM_DATA
Definition: winuser.h:721
ULONG_PTR dwItemData
Definition: winuser.h:3242
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by GetMenuItemInfoA(), and GetMenuItemInfoW().

◆ GetMenuItemInfoA()

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

Definition at line 989 of file menu.c.

994 {
995  BOOL ret;
996  MENUITEMINFOA mii;
997 
998  if( lpmii->cbSize != sizeof( mii) &&
999  lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem))
1000  {
1002  return FALSE;
1003  }
1004  memcpy( &mii, lpmii, lpmii->cbSize);
1005  mii.cbSize = sizeof( mii);
1007  item,
1008  bypos,
1009  (LPMENUITEMINFOW)&mii,
1010  FALSE);
1011  mii.cbSize = lpmii->cbSize;
1012  memcpy( lpmii, &mii, mii.cbSize);
1013  return ret;
1014 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static HMENU hmenu
Definition: win.c:66
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
int ret
static BOOL GetMenuItemInfo_common(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOW lpmii, BOOL unicode)
Definition: menu.c:175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856

Referenced by check_menu_item_info(), check_menu_items(), compare_menu_data(), correct_behavior(), test_AppendMenu(), test_menu_add_string(), test_menu_bmp_and_string(), test_menu_ownerdraw(), test_menu_resource_layout(), test_menu_search_bycommand(), test_subpopup_locked_by_menu(), and test_system_menu().

◆ GetMenuItemInfoW()

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

Definition at line 1020 of file menu.c.

1025 {
1026  BOOL ret;
1027  MENUITEMINFOW mii;
1028  if( lpmii->cbSize != sizeof( mii) && lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem))
1029  {
1031  return FALSE;
1032  }
1033  memcpy( &mii, lpmii, lpmii->cbSize);
1034  mii.cbSize = sizeof( mii);
1035  ret = GetMenuItemInfo_common (hMenu, Item, bypos, &mii, TRUE);
1036  mii.cbSize = lpmii->cbSize;
1037  memcpy( lpmii, &mii, mii.cbSize);
1038  return ret;
1039 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
int ret
static BOOL GetMenuItemInfo_common(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOW lpmii, BOOL unicode)
Definition: menu.c:175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by check_menu_item_info().

◆ GetMenuState()

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

Definition at line 1046 of file menu.c.

1050 {
1051  PITEM pItem;
1052  UINT Type = 0;
1053  TRACE("(menu=%p, id=%04x, flags=%04x);\n", hMenu, uId, uFlags);
1054  if (!(pItem = MENU_FindItem( &hMenu, &uId, uFlags ))) return -1;
1055 
1056  if (!pItem->Xlpstr && pItem->hbmp) Type = MFT_BITMAP;
1057 
1058  if (pItem->spSubMenu)
1059  {
1060  PMENU pSubMenu = DesktopPtrToUser(pItem->spSubMenu);
1061  HMENU hsubmenu = UserHMGetHandle(pSubMenu);
1062  Type |= MF_POPUP; // Fix CORE-9269
1063  if (!IsMenu(hsubmenu)) return (UINT)-1;
1064  else return (pSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|Type) & 0xff);
1065  }
1066  else
1067  return (pItem->fType | pItem->fState | Type);
1068 }
Type
Definition: Type.h:6
UINT fState
Definition: ntuser.h:341
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
#define MFT_BITMAP
Definition: winuser.h:733
UINT uFlags
Definition: api.c:60
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
BOOL WINAPI IsMenu(HMENU Menu)
Definition: menu.c:1331
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
HBITMAP hbmp
Definition: ntuser.h:356
UINT cItems
Definition: ntuser.h:389
struct tagMENU * spSubMenu
Definition: ntuser.h:343
#define MF_POPUP
Definition: winuser.h:136
unsigned int UINT
Definition: ndis.h:50
USHORT * Xlpstr
Definition: ntuser.h:346
UINT fType
Definition: ntuser.h:340
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by test_menu_circref(), test_menu_flags(), test_menu_hilitemenuitem(), test_system_menu(), and WndProc().

◆ GetMenuStringA()

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

Definition at line 1075 of file menu.c.

1081 {
1082  ITEM *item;
1083  LPWSTR text;
1085  TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, uIDItem, lpString, nMaxCount, uFlag );
1086 
1087  if (lpString && nMaxCount) lpString[0] = '\0';
1088 
1089  if (!(item = MENU_FindItem( &hMenu, &uIDItem, uFlag )))
1090  {
1092  return 0;
1093  }
1094 
1095  text = item->Xlpstr ? DesktopPtrToUser(item->Xlpstr) : NULL;
1096 
1097  if (!text) return 0;
1098  if (!lpString || !nMaxCount) return WideCharToMultiByte( CP_ACP, 0, text, -1, NULL, 0, NULL, NULL );
1099  if (!WideCharToMultiByte( CP_ACP, 0, text, -1, lpString, nMaxCount, NULL, NULL ))
1100  lpString[nMaxCount-1] = 0;
1101  TRACE("A returning %s\n", lpString);
1102  return strlen(lpString);
1103 }
Definition: fontsub.cpp:35
#define WideCharToMultiByte
Definition: compat.h:101
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937
static ATOM item
Definition: dde.c:856
LPCSTR text
Definition: menu.c:130
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ int nMaxCount
Definition: winuser.h:4778

Referenced by check_menu_item_info(), and test_menu_add_string().

◆ GetMenuStringW()

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

Definition at line 1110 of file menu.c.

1116 {
1117  ITEM *item;
1118  LPWSTR text;
1119 
1120  TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, uIDItem, lpString, nMaxCount, uFlag );
1121 
1122  if (lpString && nMaxCount) lpString[0] = '\0';
1123 
1124  if (!(item = MENU_FindItem( &hMenu, &uIDItem, uFlag )))
1125  {
1127  return 0;
1128  }
1129 
1130  text = item->Xlpstr ? DesktopPtrToUser(item->Xlpstr) : NULL;
1131 
1132  if (!lpString || !nMaxCount) return text ? strlenW(text) : 0;
1133  if( !(text))
1134  {
1135  lpString[0] = 0;
1136  return 0;
1137  }
1138  lstrcpynW( lpString, text, nMaxCount );
1139  TRACE("W returning %S\n", lpString);
1140  return strlenW(lpString);
1141 }
Definition: fontsub.cpp:35
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
#define lstrcpynW
Definition: compat.h:397
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937
static ATOM item
Definition: dde.c:856
LPCSTR text
Definition: menu.c:130
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ int nMaxCount
Definition: winuser.h:4778

Referenced by check_menu_item_info(), and test_menu_add_string().

◆ GetSubMenu()

HMENU WINAPI GetSubMenu ( HMENU  hMenu,
int  nPos 
)

Definition at line 1148 of file menu.c.

1151 {
1152  PITEM pItem;
1153  if (!(pItem = MENU_FindItem( &hMenu, (UINT*)&nPos, MF_BYPOSITION ))) return NULL;
1154 
1155  if (pItem->spSubMenu)
1156  {
1157  PMENU pSubMenu = DesktopPtrToUser(pItem->spSubMenu);
1158  HMENU hsubmenu = UserHMGetHandle(pSubMenu);
1159  if (IsMenu(hsubmenu)) return hsubmenu;
1160  }
1161  return NULL;
1162 }
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
BOOL WINAPI IsMenu(HMENU Menu)
Definition: menu.c:1331
#define MF_BYPOSITION
Definition: winuser.h:203
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
struct tagMENU * spSubMenu
Definition: ntuser.h:343
unsigned int UINT
Definition: ndis.h:50
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

◆ GetSystemMenu()

HMENU WINAPI GetSystemMenu ( HWND  hWnd,
BOOL  bRevert 
)

Definition at line 1169 of file menu.c.

1170 {
1171  return NtUserGetSystemMenu(hWnd, bRevert);
1172 }
HWND hWnd
Definition: settings.c:17
HMENU APIENTRY NtUserGetSystemMenu(HWND hWnd, BOOL bRevert)
Definition: menu.c:5661

Referenced by test_menu_bmp_and_string(), and test_system_menu().

◆ InsertMenuA()

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

Definition at line 1179 of file menu.c.

1185 {
1186  MENUITEMINFOW mii;
1188  BOOL res;
1189 
1191 
1192  MENU_mnu2mnuii( uFlags, uIDNewItem, (LPCWSTR)lpNewItem, &mii, FALSE);
1193 
1194  /* copy the text string, it will be one or the other */
1195  if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1196  {
1198  {
1200  return FALSE;
1201  }
1202  mii.dwTypeData = UnicodeString.Buffer;
1203  mii.cch = UnicodeString.Length / sizeof(WCHAR);
1204  }
1205  else
1206  {
1207  TRACE("Handle bitmaps\n");
1208  }
1209  res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), TRUE, &mii, &UnicodeString);
1211  return res;
1212 }
#define TRUE
Definition: types.h:120
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static void MENU_mnu2mnuii(UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
Definition: menu.c:529
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LPWSTR dwTypeData
Definition: winuser.h:3243
UINT uFlags
Definition: api.c:60
char * LPSTR
Definition: xmlstorage.h:182
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
#define MIIM_STRING
Definition: winuser.h:722
GLuint res
Definition: glext.h:9613
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by ChangeMenuA(), test_menu_flags(), test_menu_locked_by_window(), test_menu_search_bycommand(), and test_subpopup_locked_by_menu().

◆ InsertMenuItemA()

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

Definition at line 1219 of file menu.c.

1224 {
1225  MENUITEMINFOW mii;
1227  BOOL res;
1228 
1229  TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, fByPosition, lpmii);
1230 
1232 
1233  if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &mii )) return FALSE;
1234 
1235  /* copy the text string */
1236  if (((mii.fMask & MIIM_STRING) ||
1237  ((mii.fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(mii.fType) == MF_STRING)))
1238  && mii.dwTypeData && !(GdiValidateHandle((HGDIOBJ)mii.dwTypeData)) )
1239  {
1241  {
1243  return FALSE;
1244  }
1245  mii.dwTypeData = UnicodeString.Buffer;
1246  mii.cch = UnicodeString.Length / sizeof(WCHAR);
1247  }
1248  else
1249  {
1250  TRACE("Handle bitmaps\n");
1251  }
1252  res = NtUserThunkedMenuItemInfo(hMenu, uItem, fByPosition, TRUE, &mii, &UnicodeString);
1254  return res;
1255 }
#define TRUE
Definition: types.h:120
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
#define MF_STRING
Definition: winuser.h:138
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LPWSTR dwTypeData
Definition: winuser.h:3243
#define MENU_ITEM_TYPE(flags)
Definition: menu.c:24
char * LPSTR
Definition: xmlstorage.h:182
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
#define MIIM_TYPE
Definition: winuser.h:720
#define MIIM_STRING
Definition: winuser.h:722
BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj)
Definition: misc.c:712
GLuint res
Definition: glext.h:9613
static BOOL MENU_NormalizeMenuItemInfoStruct(const MENUITEMINFOW *pmii_in, MENUITEMINFOW *pmii_out)
Definition: menu.c:588
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by create_menuitem_from_data(), insert_menu_item(), test_AppendMenu(), test_mbs_help(), test_menu_add_string(), test_menu_search_bycommand(), test_menu_setmenuinfo(), and test_menualign().

◆ InsertMenuItemW()

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

Definition at line 1262 of file menu.c.

1267 {
1268  MENUITEMINFOW mii;
1269  UNICODE_STRING MenuText;
1270  BOOL res = FALSE;
1271 
1272  /* while we could just pass 'lpmii' to win32k, we make a copy so that
1273  if a bad user passes bad data, we crash his process instead of the
1274  entire kernel */
1275 
1276  TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, fByPosition, lpmii);
1277 
1278  RtlInitUnicodeString(&MenuText, 0);
1279 
1280  if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &mii )) return FALSE;
1281 
1282  /* copy the text string */
1283  if (((mii.fMask & MIIM_STRING) ||
1284  ((mii.fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(mii.fType) == MF_STRING)))
1285  && mii.dwTypeData && !(GdiValidateHandle((HGDIOBJ)mii.dwTypeData)) )
1286  {
1287  RtlInitUnicodeString(&MenuText, (PWSTR)lpmii->dwTypeData);
1288  mii.dwTypeData = MenuText.Buffer;
1289  mii.cch = MenuText.Length / sizeof(WCHAR);
1290  }
1291  res = NtUserThunkedMenuItemInfo(hMenu, uItem, fByPosition, TRUE, &mii, &MenuText);
1292  return res;
1293 }
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:54
#define MF_STRING
Definition: winuser.h:138
LPWSTR dwTypeData
Definition: winuser.h:3243
#define MENU_ITEM_TYPE(flags)
Definition: menu.c:24
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MIIM_TYPE
Definition: winuser.h:720
#define MIIM_STRING
Definition: winuser.h:722
BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj)
Definition: misc.c:712
GLuint res
Definition: glext.h:9613
static BOOL MENU_NormalizeMenuItemInfoStruct(const MENUITEMINFOW *pmii_in, MENUITEMINFOW *pmii_out)
Definition: menu.c:588
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by insert_menu_item(), and MENUEX_ParseResource().

◆ InsertMenuW()

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

Definition at line 1300 of file menu.c.

1306 {
1307  MENUITEMINFOW mii;
1308  UNICODE_STRING MenuText;
1309  BOOL res;
1310 
1311  RtlInitUnicodeString(&MenuText, 0);
1312 
1313  MENU_mnu2mnuii( uFlags, uIDNewItem, lpNewItem, &mii, TRUE);
1314 
1315  /* copy the text string, it will be one or the other */
1316  if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1317  {
1318  RtlInitUnicodeString(&MenuText, (PWSTR)mii.dwTypeData);
1319  mii.dwTypeData = MenuText.Buffer;
1320  mii.cch = MenuText.Length / sizeof(WCHAR);
1321  }
1322  res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), TRUE, &mii, &MenuText);
1323  return res;
1324 }
#define TRUE
Definition: types.h:120
static void MENU_mnu2mnuii(UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
Definition: menu.c:529
uint16_t * PWSTR
Definition: typedefs.h:54
LPWSTR dwTypeData
Definition: winuser.h:3243
UINT uFlags
Definition: api.c:60
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MIIM_STRING
Definition: winuser.h:722
GLuint res
Definition: glext.h:9613
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by ChangeMenuW().

◆ IntGetMenuDefaultItem()

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

Definition at line 144 of file menu.c.

145 {
146  UINT i = 0;
147  PITEM Item = Menu->rgItems ? DesktopPtrToUser(Menu->rgItems) : NULL;
148 
149  /* empty menu */
150  if (!Item) return -1;
151 
152  while ( !( Item->fState & MFS_DEFAULT ) )
153  {
154  i++; Item++;
155  if (i >= Menu->cItems ) return -1;
156  }
157 
158  /* default: don't return disabled items */
159  if ( (!(GMDI_USEDISABLED & gmdiFlags)) && (Item->fState & MFS_DISABLED )) return -1;
160 
161  /* search rekursiv when needed */
162  if ( (gmdiFlags & GMDI_GOINTOPOPUPS) && Item->spSubMenu )
163  {
164  UINT ret;
165  (*gismc)++;
166  ret = IntGetMenuDefaultItem( DesktopPtrToUser(Item->spSubMenu), fByPos, gmdiFlags, gismc );
167  (*gismc)--;
168  if ( -1 != ret ) return ret;
169 
170  /* when item not found in submenu, return the popup item */
171  }
172  return ( fByPos ) ? i : Item->wID;
173 }
UINT wID
Definition: ntuser.h:342
UINT fState
Definition: ntuser.h:341
#define MFS_DISABLED
Definition: winuser.h:744
#define MFS_DEFAULT
Definition: winuser.h:743
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 __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
#define GMDI_GOINTOPOPUPS
Definition: winuser.h:2107
smooth NULL
Definition: ftsmooth.c:416
UINT FASTCALL IntGetMenuDefaultItem(PMENU MenuObject, UINT fByPos, UINT gmdiFlags, DWORD *gismc)
Definition: menu.c:1315
UINT cItems
Definition: ntuser.h:389
PITEM rgItems
Definition: ntuser.h:394
int ret
struct tagMENU * spSubMenu
Definition: ntuser.h:343
#define GMDI_USEDISABLED
Definition: winuser.h:2108
unsigned int UINT
Definition: ndis.h:50

◆ IsMenu()

BOOL WINAPI IsMenu ( HMENU  Menu)

Definition at line 1331 of file menu.c.

1333 {
1334  if (ValidateHandle(Menu, TYPE_MENU)) return TRUE;
1335  return FALSE;
1336 }
#define TRUE
Definition: types.h:120
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:717

Referenced by get_bad_hmenu(), GetMenuState(), GetSubMenu(), MENU_NormalizeMenuItemInfoStruct(), test_menu_locked_by_window(), and test_subpopup_locked_by_menu().

◆ LoadMenuA()

HMENU WINAPI LoadMenuA ( HINSTANCE  hInstance,
LPCSTR  lpMenuName 
)

Definition at line 1342 of file menu.c.

1344 {
1346  if (Resource == NULL)
1347  {
1348  return(NULL);
1349  }
1351 }
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
HINSTANCE hInstance
Definition: charmap.c:20
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:848
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
HMENU WINAPI LoadMenuIndirectA(CONST MENUTEMPLATE *lpMenuTemplate)
Definition: menu.c:1357

Referenced by test_CheckMenuRadioItem().

◆ LoadMenuIndirectA()

HMENU WINAPI LoadMenuIndirectA ( CONST MENUTEMPLATE lpMenuTemplate)

Definition at line 1357 of file menu.c.

1358 {
1359  return(LoadMenuIndirectW(lpMenuTemplate));
1360 }
HMENU WINAPI LoadMenuIndirectW(CONST MENUTEMPLATE *lpMenuTemplate)
Definition: menu.c:1366

Referenced by LoadMenuA(), and test_menu_resource_layout().

◆ LoadMenuIndirectW()

HMENU WINAPI LoadMenuIndirectW ( CONST MENUTEMPLATE lpMenuTemplate)

Definition at line 1366 of file menu.c.

1367 {
1368  HMENU hMenu;
1369  WORD version, offset;
1370  LPCSTR p = (LPCSTR)lpMenuTemplate;
1371 
1372  version = GET_WORD(p);
1373  p += sizeof(WORD);
1374 
1375  switch (version)
1376  {
1377  case 0: /* standard format is version of 0 */
1378  offset = GET_WORD(p);
1379  p += sizeof(WORD) + offset;
1380  if (!(hMenu = CreateMenu())) return 0;
1381  if (!MENU_ParseResource(p, hMenu))
1382  {
1383  DestroyMenu(hMenu);
1384  return 0;
1385  }
1386  return hMenu;
1387  case 1: /* extended format is version of 1 */
1388  offset = GET_WORD(p);
1389  p += sizeof(WORD) + offset;
1390  if (!(hMenu = CreateMenu())) return 0;
1391  if (!MENUEX_ParseResource(p, hMenu))
1392  {
1393  DestroyMenu( hMenu );
1394  return 0;
1395  }
1396  return hMenu;
1397  default:
1398  ERR("Menu template version %d not supported.\n", version);
1399  return 0;
1400  }
1401 }
GLintptr offset
Definition: glext.h:5920
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
static LPCSTR MENU_ParseResource(LPCSTR res, HMENU hMenu)
Definition: menu.c:418
static const WCHAR version[]
Definition: asmname.c:64
const char * LPCSTR
Definition: xmlstorage.h:183
#define GET_WORD(ptr)
Definition: menu.c:68
static LPCSTR MENUEX_ParseResource(LPCSTR res, HMENU hMenu)
Definition: menu.c:463
unsigned short WORD
Definition: ntddk_ex.h:93
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define ERR(fmt,...)
Definition: debug.h:109
GLfloat GLfloat p
Definition: glext.h:8902
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by LoadMenuIndirectA(), and LoadMenuW().

◆ LoadMenuW()

HMENU WINAPI LoadMenuW ( HINSTANCE  hInstance,
LPCWSTR  lpMenuName 
)

Definition at line 1407 of file menu.c.

1409 {
1410  HANDLE Resource = FindResourceW(hInstance, lpMenuName, RT_MENU);
1411  if (Resource == NULL)
1412  {
1413  return(NULL);
1414  }
1416 }
HMENU WINAPI LoadMenuIndirectW(CONST MENUTEMPLATE *lpMenuTemplate)
Definition: menu.c:1366
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HINSTANCE hInstance
Definition: charmap.c:20
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:848
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
#define RT_MENU
Definition: pedump.c:366

Referenced by User32CallLoadMenuFromKernel().

◆ MENU_FindItem()

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

Definition at line 91 of file menu.c.

92 {
93  MENU *menu;
94  ITEM *fallback = NULL;
95  UINT fallback_pos = 0;
96  UINT i;
97  PITEM pItem;
98 
99  if ((*hmenu == (HMENU)0xffff) || (!(menu = MENU_GetMenu(*hmenu)))) return NULL;
100  if (wFlags & MF_BYPOSITION)
101  {
102  if (*nPos >= menu->cItems) return NULL;
103  pItem = menu->rgItems ? DesktopPtrToUser(menu->rgItems) : NULL;
104  if (pItem) pItem = &pItem[*nPos];
105  return pItem;
106  }
107  else
108  {
109  PITEM item = menu->rgItems ? DesktopPtrToUser(menu->rgItems) : NULL;
110  for (i = 0; item && (i < menu->cItems); i++, item++)
111  {
112  if (item->spSubMenu)
113  {
114  PMENU pSubMenu = DesktopPtrToUser(item->spSubMenu);
115  HMENU hsubmenu = UserHMGetHandle(pSubMenu);
116  ITEM *subitem = MENU_FindItem( &hsubmenu, nPos, wFlags );
117  if (subitem)
118  {
119  *hmenu = hsubmenu;
120  return subitem;
121  }
122  else if (item->wID == *nPos)
123  {
124  /* fallback to this item if nothing else found */
125  fallback_pos = i;
126  fallback = item;
127  }
128  }
129  else if (item->wID == *nPos)
130  {
131  *nPos = i;
132  return item;
133  }
134  }
135  }
136 
137  if (fallback)
138  *nPos = fallback_pos;
139 
140  return fallback;
141 }
Definition: fontsub.cpp:35
FORCEINLINE PMENU MENU_GetMenu(HMENU hMenu)
Definition: menu.c:80
static HMENU hmenu
Definition: win.c:66
PITEM FASTCALL MENU_FindItem(PMENU *pmenu, UINT *nPos, UINT wFlags)
Definition: menu.c:507
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
#define MF_BYPOSITION
Definition: winuser.h:203
smooth NULL
Definition: ftsmooth.c:416
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
UINT cItems
Definition: ntuser.h:389
PITEM rgItems
Definition: ntuser.h:394
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

◆ MENU_GetMenu()

FORCEINLINE PMENU MENU_GetMenu ( HMENU  hMenu)

Definition at line 80 of file menu.c.

81 {
82  return ValidateHandleNoErr(hMenu, TYPE_MENU);
83 }
PVOID FASTCALL ValidateHandleNoErr(HANDLE handle, UINT uType)
Definition: misc.c:320

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

530 {
531  RtlZeroMemory( pmii, sizeof( MENUITEMINFOW));
532  pmii->cbSize = sizeof( MENUITEMINFOW);
533  pmii->fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE;
534  /* setting bitmap clears text and vice versa */
535  if( IS_STRING_ITEM(flags)) {
536  pmii->fMask |= MIIM_STRING | MIIM_BITMAP;
537  if( !str)
538  flags |= MF_SEPARATOR;
539  /* Item beginning with a backspace is a help item */
540  /* FIXME: wrong place, this is only true in win16 */
541  else
542  {
543  if (Unicode)
544  {
545  if (*str == '\b')
546  {
547  flags |= MF_HELP;
548  str++;
549  }
550  }
551  else
552  {
553  LPCSTR NewItemA = (LPCSTR) str;
554  if (*NewItemA == '\b')
555  {
556  flags |= MF_HELP;
557  NewItemA++;
558  str = (LPCWSTR) NewItemA;
559  }
560  TRACE("A cch %d\n",strlen(NewItemA));
561  }
562  }
563  pmii->dwTypeData = (LPWSTR)str;
564  } else if( flags & MFT_BITMAP){
565  pmii->fMask |= MIIM_BITMAP | MIIM_STRING;
566  pmii->hbmpItem = (HBITMAP)str;
567  }
568  if( flags & MF_OWNERDRAW){
569  pmii->fMask |= MIIM_DATA;
570  pmii->dwItemData = (ULONG_PTR) str;
571  }
572  if( flags & MF_POPUP && MENU_GetMenu((HMENU)id)) {
573  pmii->fMask |= MIIM_SUBMENU;
574  pmii->hSubMenu = (HMENU)id;
575  }
579  pmii->wID = (UINT)id;
580 }
#define MIIM_FTYPE
Definition: winuser.h:724
#define MF_DISABLED
Definition: winuser.h:130
FORCEINLINE PMENU MENU_GetMenu(HMENU hMenu)
Definition: menu.c:80
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LPWSTR dwTypeData
Definition: winuser.h:3243
#define MFT_BITMAP
Definition: winuser.h:733
#define MFS_DEFAULT
Definition: winuser.h:743
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:28
#define MIIM_BITMAP
Definition: winuser.h:723
static UINT(WINAPI *pSendInput)(UINT
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MIIM_STATE
Definition: winuser.h:716
const WCHAR * str
#define MF_OWNERDRAW
Definition: winuser.h:135
#define MF_SEPARATOR
Definition: winuser.h:137
const char * LPCSTR
Definition: xmlstorage.h:183
#define MIIM_ID
Definition: winuser.h:717
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
#define MF_POPUP
Definition: winuser.h:136
#define MIIM_STRING
Definition: winuser.h:722
#define MENUITEMINFO_STATE_MASK
Definition: menu.c:37
GLenum GLuint id
Definition: glext.h:5579
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
static HBITMAP
Definition: button.c:44
#define MF_HELP
Definition: winuser.h:142
#define MF_GRAYED
Definition: winuser.h:129
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define MIIM_DATA
Definition: winuser.h:721
ULONG_PTR dwItemData
Definition: winuser.h:3242
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
struct tagMENUITEMINFOW MENUITEMINFOW
#define IS_STRING_ITEM(flags)
Definition: menu.c:42

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

590 {
591  /* do we recognize the size? */
592  if( !pmii_in || (pmii_in->cbSize != sizeof( MENUITEMINFOW) &&
593  pmii_in->cbSize != sizeof( MENUITEMINFOW) - sizeof( pmii_in->hbmpItem)) ) {
595  return FALSE;
596  }
597  /* copy the fields that we have */
598  memcpy( pmii_out, pmii_in, pmii_in->cbSize);
599  /* if the hbmpItem member is missing then extend */
600  if( pmii_in->cbSize != sizeof( MENUITEMINFOW)) {
601  pmii_out->cbSize = sizeof( MENUITEMINFOW);
602  pmii_out->hbmpItem = NULL;
603  }
604  /* test for invalid bit combinations */
605  if( (pmii_out->fMask & MIIM_TYPE &&
606  pmii_out->fMask & (MIIM_STRING | MIIM_FTYPE | MIIM_BITMAP)) ||
607  (pmii_out->fMask & MIIM_FTYPE && pmii_out->fType & MFT_BITMAP)) {
608  ERR("invalid combination of fMask bits used\n");
609  /* this does not happen on Win9x/ME */
611  return FALSE;
612  }
613  /* convert old style (MIIM_TYPE) to the new and keep the old one too */
614  if( pmii_out->fMask & MIIM_TYPE){
615  pmii_out->fMask |= MIIM_FTYPE;
616  if( IS_STRING_ITEM(pmii_out->fType)){
617  pmii_out->fMask |= MIIM_STRING;
618  } else if( (pmii_out->fType) & MFT_BITMAP){
619  pmii_out->fMask |= MIIM_BITMAP;
620  pmii_out->hbmpItem = UlongToHandle(LOWORD(pmii_out->dwTypeData));
621  }
622  }
623  if (pmii_out->fMask & MIIM_FTYPE )
624  {
625  pmii_out->fType &= ~MENUITEMINFO_TYPE_MASK;
626  pmii_out->fType |= pmii_in->fType & MENUITEMINFO_TYPE_MASK;
627  }
628  if (pmii_out->fMask & MIIM_STATE)
629  /* Other menu items having MFS_DEFAULT are not converted
630  to normal items */
631  pmii_out->fState = pmii_in->fState & MENUITEMINFO_STATE_MASK;
632 
633  if (pmii_out->fMask & MIIM_SUBMENU)
634  {
635  if ((pmii_out->hSubMenu != NULL) && !IsMenu(pmii_out->hSubMenu))
636  return FALSE;
637  }
638 
639  return TRUE;
640 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
LPWSTR dwTypeData
Definition: winuser.h:3243
#define MFT_BITMAP
Definition: winuser.h:733
#define MENUITEMINFO_TYPE_MASK
Definition: menu.c:28
#define MIIM_BITMAP
Definition: winuser.h:723
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MIIM_STATE
Definition: winuser.h:716
BOOL WINAPI IsMenu(HMENU Menu)
Definition: menu.c:1331
smooth NULL
Definition: ftsmooth.c:416
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define SetLastError(x)
Definition: compat.h:409
#define MIIM_TYPE
Definition: winuser.h:720
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
#define MIIM_STRING
Definition: winuser.h:722
#define MENUITEMINFO_STATE_MASK
Definition: menu.c:37
#define LOWORD(l)
Definition: pedump.c:82
struct tagMENUITEMINFOW MENUITEMINFOW
#define IS_STRING_ITEM(flags)
Definition: menu.c:42

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

◆ MENU_ParseResource()

static LPCSTR MENU_ParseResource ( LPCSTR  res,
HMENU  hMenu 
)
static

Definition at line 418 of file menu.c.

419 {
420  WORD flags, id = 0;
421  HMENU hSubMenu;
422  LPCWSTR str;
423  BOOL end = FALSE;
424 
425  do
426  {
427  flags = GET_WORD(res);
428 
429  /* remove MF_END flag before passing it to AppendMenu()! */
430  end = (flags & MF_END);
431  if(end) flags ^= MF_END;
432 
433  res += sizeof(WORD);
434  if(!(flags & MF_POPUP))
435  {
436  id = GET_WORD(res);
437  res += sizeof(WORD);
438  }
439  str = (LPCWSTR)res;
440  res += (strlenW(str) + 1) * sizeof(WCHAR);
441 
442  if (flags & MF_POPUP)
443  {
444  hSubMenu = CreatePopupMenu();
445  if(!hSubMenu) return NULL;
446  if(!(res = MENU_ParseResource(res, hSubMenu))) return NULL;
447  AppendMenuW(hMenu, flags, (UINT_PTR)hSubMenu, (LPCWSTR)str);
448  }
449  else /* Not a popup */
450  {
451  AppendMenuW(hMenu, flags, id, *(LPCWSTR)str ? (LPCWSTR)str : NULL);
452  }
453  } while(!end);
454  return res;
455 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLuint GLuint end
Definition: gl.h:1545
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
unsigned int BOOL
Definition: ntddk_ex.h:94
static LPCSTR MENU_ParseResource(LPCSTR res, HMENU hMenu)
Definition: menu.c:418
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define MF_END
Definition: winuser.h:143
#define GET_WORD(ptr)
Definition: menu.c:68
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
GLbitfield flags
Definition: glext.h:7161
#define MF_POPUP
Definition: winuser.h:136
BOOL WINAPI AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:722
GLuint res
Definition: glext.h:9613
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by LoadMenuIndirectW().

◆ MenuCleanup()

VOID MenuCleanup ( VOID  )

Definition at line 649 of file menu.c.

650 {
651 }

Referenced by Cleanup().

◆ MENUEX_ParseResource()

static LPCSTR MENUEX_ParseResource ( LPCSTR  res,
HMENU  hMenu 
)
static

Definition at line 463 of file menu.c.

464 {
465  WORD resinfo;
466  do
467  {
468  MENUITEMINFOW mii;
469 
470  mii.cbSize = sizeof(mii);
471  mii.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
472  mii.fType = GET_DWORD(res);
473  res += sizeof(DWORD);
474  mii.fState = GET_DWORD(res);
475  res += sizeof(DWORD);
476  mii.wID = GET_DWORD(res);
477  res += sizeof(DWORD);
478  resinfo = GET_WORD(res);
479  res += sizeof(WORD);
480  /* Align the text on a word boundary. */
481  res += (~((UINT_PTR)res - 1)) & 1;
482  mii.dwTypeData = (LPWSTR)res;
483  mii.cch = strlenW(mii.dwTypeData);
484  res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR);
485  /* Align the following fields on a dword boundary. */
486  res += (~((UINT_PTR)res - 1)) & 3;
487 
488  TRACE("Menu item: [%08x,%08x,%04x,%04x,%S]\n",
489  mii.fType, mii.fState, mii.wID, resinfo, mii.dwTypeData);
490 
491  if (resinfo & 1) /* Pop-up? */
492  {
493  /* DWORD helpid = GET_DWORD(res); FIXME: use this. */
494  res += sizeof(DWORD);
495  mii.hSubMenu = CreatePopupMenu();
496  if (!mii.hSubMenu)
497  {
498  ERR("CreatePopupMenu failed\n");
499  return NULL;
500  }
501 
502  if (!(res = MENUEX_ParseResource(res, mii.hSubMenu)))
503  {
504  ERR("MENUEX_ParseResource failed\n");
505  DestroyMenu(mii.hSubMenu);
506  return NULL;
507  }
508  mii.fMask |= MIIM_SUBMENU;
509  mii.fType |= MF_POPUP;
510  }
511  else if (!mii.dwTypeData[0] && !(mii.fType & MF_SEPARATOR))
512  {
513  WARN("Converting NULL menu item %04x, type %04x to SEPARATOR\n",
514  mii.wID, mii.fType);
515  mii.fType |= MF_SEPARATOR;
516  }
517  InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii);
518  } while (!(resinfo & MF_END));
519  return res;
520 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define GET_DWORD(ptr)
Definition: menu.c:71
#define WARN(fmt,...)
Definition: debug.h:111
LPWSTR dwTypeData
Definition: winuser.h:3243
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
#define DWORD
Definition: nt_native.h:44
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MIIM_STATE
Definition: winuser.h:716
#define MF_BYPOSITION
Definition: winuser.h:203
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
#define MF_END
Definition: winuser.h:143
#define MIIM_ID
Definition: winuser.h:717
#define GET_WORD(ptr)
Definition: menu.c:68
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static LPCSTR MENUEX_ParseResource(LPCSTR res, HMENU hMenu)
Definition: menu.c:463
unsigned short WORD
Definition: ntddk_ex.h:93
#define MF_POPUP
Definition: winuser.h:136
#define MIIM_TYPE
Definition: winuser.h:720
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define ERR(fmt,...)
Definition: debug.h:109
BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
Definition: menu.c:1262
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by LoadMenuIndirectW().

◆ MenuInit()

BOOL MenuInit ( VOID  )

Definition at line 643 of file menu.c.

644 {
645  return TRUE;
646 }
#define TRUE
Definition: types.h:120

◆ MenuWindowProcA()

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

Definition at line 1674 of file menu.c.

1681 {
1682  if ( Msg < WM_USER)
1683  {
1684  return PopupMenuWndProcA(hWnd, Msg, wParam, lParam );
1685  }
1687 }
#define TRUE
Definition: types.h:120
#define FNID_MENU
Definition: ntuser.h:823
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
_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:426
struct @1580 Msg[]
BOOL NTAPI NtUserMessageCall(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
Definition: message.c:2323
#define WM_USER
Definition: winuser.h:1877
LRESULT WINAPI PopupMenuWndProcA(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: menu.c:376
LPARAM lParam
Definition: combotst.c:139

◆ MenuWindowProcW()

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

Definition at line 1694 of file menu.c.

1701 {
1702  if ( Msg < WM_USER)
1703  {
1704  return PopupMenuWndProcW(hWnd, Msg, wParam, lParam );
1705  }
1707 }
#define FNID_MENU
Definition: ntuser.h:823
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
_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:426
struct @1580 Msg[]
BOOL NTAPI NtUserMessageCall(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
Definition: message.c:2323
#define WM_USER
Definition: winuser.h:1877
LRESULT WINAPI PopupMenuWndProcW(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: menu.c:305
LPARAM lParam
Definition: combotst.c:139

◆ ModifyMenuA()

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

Definition at line 1423 of file menu.c.

1429 {
1430  MENUITEMINFOW mii;
1432  BOOL res;
1433 
1435 
1436  MENU_mnu2mnuii( uFlags, uIDNewItem, (LPCWSTR)lpNewItem, &mii, FALSE);
1437 
1438  /* copy the text string, it will be one or the other */
1439  if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1440  {
1442  {
1444  return FALSE;
1445  }
1446  mii.dwTypeData = UnicodeString.Buffer;
1447  mii.cch = UnicodeString.Length / sizeof(WCHAR);
1448  }
1449  else
1450  {
1451  TRACE("Handle bitmaps\n");
1452  }
1453  res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), FALSE, &mii, &UnicodeString);
1455  return res;
1456 }
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static void MENU_mnu2mnuii(UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
Definition: menu.c:529
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LPWSTR dwTypeData
Definition: winuser.h:3243
UINT uFlags
Definition: api.c:60
char * LPSTR
Definition: xmlstorage.h:182
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
#define MIIM_STRING
Definition: winuser.h:722
GLuint res
Definition: glext.h:9613
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by ChangeMenuA(), modify_menu(), test_AppendMenu(), test_menu_circref(), test_menu_flags(), test_menu_ownerdraw(), and test_system_menu().

◆ ModifyMenuW()

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

Definition at line 1463 of file menu.c.

1469 {
1470  MENUITEMINFOW mii;
1471  UNICODE_STRING MenuText;
1472  BOOL res;
1473 
1474  RtlInitUnicodeString(&MenuText, 0);
1475 
1476  MENU_mnu2mnuii( uFlags, uIDNewItem, lpNewItem, &mii, TRUE);
1477 
1478  /* copy the text string, it will be one or the other */
1479  if (lpNewItem && mii.fMask & MIIM_STRING && !mii.hbmpItem && mii.dwTypeData)
1480  {
1481  RtlInitUnicodeString(&MenuText, (PWSTR)mii.dwTypeData);
1482  mii.dwTypeData = MenuText.Buffer;
1483  mii.cch = MenuText.Length / sizeof(WCHAR);
1484  }
1485  else
1486  {
1487  TRACE("Handle bitmaps\n");
1488  }
1489  res = NtUserThunkedMenuItemInfo(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), FALSE, &mii, &MenuText);
1490  return res;
1491 }
#define TRUE
Definition: types.h:120
static void MENU_mnu2mnuii(UINT flags, UINT_PTR id, LPCWSTR str, LPMENUITEMINFOW pmii, BOOL Unicode)
Definition: menu.c:529
uint16_t * PWSTR
Definition: typedefs.h:54
LPWSTR dwTypeData
Definition: winuser.h:3243
UINT uFlags
Definition: api.c:60
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MIIM_STRING
Definition: winuser.h:722
GLuint res
Definition: glext.h:9613
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by ChangeMenuW(), modify_menu(), and test_system_menu().

◆ PopupMenuWndProcA()

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

Definition at line 376 of file menu.c.

377 {
378  PWND pWnd;
379 
380  pWnd = ValidateHwnd(Wnd);
381  if (pWnd && !pWnd->fnid && Message != WM_NCCREATE)
382  {
383  return DefWindowProcA(Wnd, Message, wParam, lParam);
384  }
385  TRACE("YES! hwnd=%x msg=0x%04x wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
386 
387  switch(Message)
388  {
389  case WM_NCCREATE:
390  case WM_CREATE:
391  case WM_MOUSEACTIVATE:
392  case WM_PAINT:
393  case WM_PRINTCLIENT:
394  case WM_ERASEBKGND:
395  case WM_DESTROY:
396  case WM_NCDESTROY:
397  case WM_SHOWWINDOW:
398  case MM_SETMENUHANDLE:
399  case MM_GETMENUHANDLE:
400  case MN_SETHMENU:
401  case MN_GETHMENU:
402  return PopupMenuWndProcW(Wnd, Message, wParam, lParam);
403 
404  default:
405  return DefWindowProcA(Wnd, Message, wParam, lParam);
406  }
407  return 0;
408 }
#define WM_SHOWWINDOW
Definition: winuser.h:1610
#define MN_SETHMENU
Definition: undocuser.h:52
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define MM_GETMENUHANDLE
Definition: menu.c:20
#define MN_GETHMENU
Definition: winuser.h:1755
DWORD fnid
Definition: ntuser.h:673
#define WM_MOUSEACTIVATE
Definition: winuser.h:1619
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_NCDESTROY
Definition: winuser.h:1666
#define WM_PAINT
Definition: winuser.h:1602
CHAR Message[80]
Definition: alive.c:5
#define MM_SETMENUHANDLE
Definition: menu.c:19
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: ntuser.h:657
LRESULT WINAPI PopupMenuWndProcW(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: menu.c:305
#define WM_CREATE
Definition: winuser.h:1590
#define WM_ERASEBKGND
Definition: winuser.h:1607
LPARAM lParam
Definition: combotst.c:139

Referenced by MenuWindowProcA(), and RegisterClientPFN().

◆ PopupMenuWndProcW()

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

Definition at line 305 of file menu.c.

306 {
307  LRESULT lResult;
308  PWND pWnd;
309 
310  TRACE("PMWPW : hwnd=%x msg=0x%04x wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam);
311 
312  pWnd = ValidateHwnd(Wnd);
313  if (pWnd)
314  {
315  if (!pWnd->fnid)
316  {
317  if (Message != WM_NCCREATE)
318  {
319  return DefWindowProcW(Wnd, Message, wParam, lParam);
320  }
321  }
322  else
323  {
324  if (pWnd->fnid != FNID_MENU)
325  {
326  ERR("Wrong window class for Menu!\n");
327  return 0;
328  }
329  }
330  }
331 
332  switch(Message)
333  {
334  case WM_DESTROY:
335  case WM_NCDESTROY:
336  case WM_NCCREATE:
337  case WM_CREATE:
338  case MM_SETMENUHANDLE:
339  case MM_GETMENUHANDLE:
340  case MN_SETHMENU:
341  case MN_GETHMENU:
342  case WM_PAINT:
343  case WM_PRINTCLIENT:
344  {
345  TRACE("Menu Class ProcW\n");
347  return lResult;
348  }
349  case WM_MOUSEACTIVATE: /* We don't want to be activated */
350  return MA_NOACTIVATE;
351 
352  case WM_ERASEBKGND:
353  return 1;
354 
355  case WM_SHOWWINDOW: // Not sure what this does....
356  if (0 != wParam)
357  {
358  if (0 == GetWindowLongPtrW(Wnd, 0))
359  {
360  OutputDebugStringA("no menu to display\n");
361  }
362  }
363  else
364  {
365  //SetWindowLongPtrW(Wnd, 0, 0);
366  }
367  break;
368 
369  default:
370  return DefWindowProcW(Wnd, Message, wParam, lParam);
371  }
372 
373  return 0;
374 }
#define FNID_MENU
Definition: ntuser.h:823
#define WM_SHOWWINDOW
Definition: winuser.h:1610
#define MN_SETHMENU
Definition: undocuser.h:52
#define GetWindowLongPtrW
Definition: winuser.h:4730
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define MM_GETMENUHANDLE
Definition: menu.c:20
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define MN_GETHMENU
Definition: winuser.h:1755
DWORD fnid
Definition: ntuser.h:673
#define WM_MOUSEACTIVATE
Definition: winuser.h:1619
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_NCDESTROY
Definition: winuser.h:1666
#define WM_PAINT
Definition: winuser.h:1602
CHAR Message[80]
Definition: alive.c:5
#define MM_SETMENUHANDLE
Definition: menu.c:19
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
#define MA_NOACTIVATE
Definition: winuser.h:2478
BOOL NTAPI NtUserMessageCall(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
Definition: message.c:2323
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
#define WM_CREATE
Definition: winuser.h:1590
#define WM_ERASEBKGND
Definition: winuser.h:1607
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18

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

◆ SetMenu()

BOOL WINAPI SetMenu ( HWND  hWnd,
HMENU  hMenu 
)

Definition at line 1497 of file menu.c.

1499 {
1500  return NtUserSetMenu(hWnd, hMenu, TRUE);
1501 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
BOOL APIENTRY NtUserSetMenu(HWND hWnd, HMENU Menu, BOOL Repaint)
Definition: menu.c:6405

Referenced by test_getmenubarinfo(), test_mbs_help(), test_menu_cancelmode(), test_menu_hilitemenuitem(), test_menu_input(), test_menu_locked_by_window(), and test_menu_ownerdraw().

◆ SetMenuInfo()

BOOL WINAPI SetMenuInfo ( HMENU  hmenu,
LPCMENUINFO  lpcmi 
)

Definition at line 1508 of file menu.c.

1511 {
1512  MENUINFO mi;
1513  BOOL res = FALSE;
1514 
1515  if (!lpcmi || (lpcmi->cbSize != sizeof(MENUINFO)))
1516  {
1518  return res;
1519  }
1520 
1521  memcpy(&mi, lpcmi, sizeof(MENUINFO));
1523 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static HMENU hmenu
Definition: win.c:66
static MONITORINFO mi
Definition: win.c:7331
MENUINFO CONST * LPCMENUINFO
Definition: winuser.h:3718
BOOL APIENTRY NtUserThunkedMenuInfo(HMENU hMenu, LPCMENUINFO lpcmi)
Definition: menu.c:6529
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint res
Definition: glext.h:9613

Referenced by init_function_pointers().

◆ SetMenuItemBitmaps()

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

Definition at line 1530 of file menu.c.

1536 {
1537  MENUITEMINFOW uItem;
1538  memset ( &uItem, 0, sizeof(uItem) );
1539  uItem.cbSize = sizeof(MENUITEMINFOW);
1540  uItem.fMask = MIIM_CHECKMARKS;
1541  uItem.hbmpUnchecked = hBitmapUnchecked;
1542  uItem.hbmpChecked = hBitmapChecked;
1543  return SetMenuItemInfoW(hMenu, uPosition, (BOOL)(uFlags & MF_BYPOSITION), &uItem);
1544 }
HBITMAP hbmpChecked
Definition: winuser.h:3240
UINT uFlags
Definition: api.c:60
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI SetMenuItemInfoW(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
Definition: menu.c:1599
#define MIIM_CHECKMARKS
Definition: winuser.h:719
HBITMAP hbmpUnchecked
Definition: winuser.h:3241
#define memset(x, y, z)
Definition: compat.h:39
struct tagMENUITEMINFOW MENUITEMINFOW

◆ SetMenuItemInfoA()

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

Definition at line 1551 of file menu.c.

1556 {
1557  MENUITEMINFOW mii;
1559  BOOL Ret;
1560 
1561  TRACE("hmenu %p, item %u, by pos %d, info %p\n", hmenu, item, bypos, lpmii);
1562 
1564 
1565  if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &mii )) return FALSE;
1566 /*
1567  * MIIM_STRING == good
1568  * MIIM_TYPE & MFT_STRING == good
1569  * MIIM_STRING & MFT_STRING == good
1570  * MIIM_STRING & MFT_OWNERDRAW == good
1571  */
1572  if (((mii.fMask & MIIM_STRING) ||
1573  ((mii.fMask & MIIM_TYPE) && (MENU_ITEM_TYPE(mii.fType) == MF_STRING)))
1574  && mii.dwTypeData && !(GdiValidateHandle((HGDIOBJ)mii.dwTypeData)) )
1575  {
1576  /* cch is ignored when the content of a menu item is set by calling SetMenuItemInfo. */
1578  {
1580  return FALSE;
1581  }
1582  mii.dwTypeData = UnicodeString.Buffer;
1583  mii.cch = UnicodeString.Length / sizeof(WCHAR);
1584  }
1585  else
1586  {
1587  UnicodeString.Buffer = NULL;
1588  }
1589  Ret = NtUserThunkedMenuItemInfo(hmenu, item, bypos, FALSE, &mii, &UnicodeString);
1591  return Ret;
1592 }
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
static HMENU hmenu
Definition: win.c:66
#define MF_STRING
Definition: winuser.h:138
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LPWSTR dwTypeData
Definition: winuser.h:3243
#define MENU_ITEM_TYPE(flags)
Definition: menu.c:24
char * LPSTR
Definition: xmlstorage.h:182
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
#define MIIM_TYPE
Definition: winuser.h:720
#define MIIM_STRING
Definition: winuser.h:722
BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj)
Definition: misc.c:712
static ATOM item
Definition: dde.c:856
static BOOL MENU_NormalizeMenuItemInfoStruct(const MENUITEMINFOW *pmii_in, MENUITEMINFOW *pmii_out)
Definition: menu.c:588
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by clear_ftype_and_state(), set_menu_item_info(), test_AppendMenu(), test_menu_add_string(), test_menu_search_bycommand(), test_menualign(), and test_system_menu().

◆ SetMenuItemInfoW()

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

Definition at line 1599 of file menu.c.

1604 {
1605  MENUITEMINFOW MenuItemInfoW;
1607  BOOL Ret;
1608 
1609  TRACE("hmenu %p, item %u, by pos %d, info %p\n", hMenu, uItem, fByPosition, lpmii);
1610 
1612 
1613  if (!MENU_NormalizeMenuItemInfoStruct( (const MENUITEMINFOW *)lpmii, &MenuItemInfoW )) return FALSE;
1614 
1615  if (((MenuItemInfoW.fMask & MIIM_STRING) ||
1616  ((MenuItemInfoW.fMask & MIIM_TYPE) &&
1617  (MENU_ITEM_TYPE(MenuItemInfoW.fType) == MF_STRING)))
1618  && MenuItemInfoW.dwTypeData && !(GdiValidateHandle((HGDIOBJ)MenuItemInfoW.dwTypeData)) )
1619  {
1621  MenuItemInfoW.cch = strlenW(MenuItemInfoW.dwTypeData);
1622  }
1623  Ret = NtUserThunkedMenuItemInfo(hMenu, uItem, fByPosition, FALSE, &MenuItemInfoW, &UnicodeString);
1624 
1625  return Ret;
1626 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define MF_STRING
Definition: winuser.h:138
LPWSTR dwTypeData
Definition: winuser.h:3243
#define MENU_ITEM_TYPE(flags)
Definition: menu.c:24
BOOL APIENTRY NtUserThunkedMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, BOOL bInsert, LPMENUITEMINFOW lpmii, PUNICODE_STRING lpszCaption)
Definition: menu.c:6556
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define MIIM_TYPE
Definition: winuser.h:720
#define MIIM_STRING
Definition: winuser.h:722
BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj)
Definition: misc.c:712
static BOOL MENU_NormalizeMenuItemInfoStruct(const MENUITEMINFOW *pmii_in, MENUITEMINFOW *pmii_out)
Definition: menu.c:588
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by set_menu_item_info(), SetMenuItemBitmaps(), and test_system_menu().

◆ SetSystemMenu()

BOOL WINAPI SetSystemMenu ( HWND  hwnd,
HMENU  hMenu 
)

Definition at line 1633 of file menu.c.

1636 {
1637  if(!hwnd)
1638  {
1640  return FALSE;
1641  }
1642  if(!hMenu)
1643  {
1645  return FALSE;
1646  }
1647  return NtUserSetSystemMenu(hwnd, hMenu);
1648 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define SetLastError(x)
Definition: compat.h:409
BOOL APIENTRY NtUserSetSystemMenu(HWND hWnd, HMENU hMenu)
Definition: menu.c:5696

◆ TrackPopupMenu()

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

Definition at line 1652 of file menu.c.

1660 {
1661  return NtUserTrackPopupMenuEx( Menu,
1662  Flags,
1663  x,
1664  y,
1665  Wnd,
1666  NULL); // LPTPMPARAMS is null
1667 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
BOOL APIENTRY NtUserTrackPopupMenuEx(HMENU hMenu, UINT fuFlags, int x, int y, HWND hWnd, LPTPMPARAMS lptpm)
Definition: menu.c:6616
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by menu_track_again_wnd_proc(), MyTrackPopupMenu(), test_emptypopup(), test_mbs_help(), test_menu_cancelmode(), test_menu_ownerdraw(), test_menu_trackagain(), test_menualign(), and test_subpopup_locked_by_menu().

◆ User32CallLoadMenuFromKernel()

NTSTATUS WINAPI User32CallLoadMenuFromKernel ( PVOID  Arguments,
ULONG  ArgumentLength 
)

Definition at line 665 of file menu.c.

666 {
668  LRESULT Result;
669 
670  Common = (PLOADMENU_CALLBACK_ARGUMENTS) Arguments;
671 
672  Result = (LRESULT)LoadMenuW( Common->hModule, Common->InterSource ? MAKEINTRESOURCE(Common->InterSource) : (LPCWSTR)&Common->MenuName);
673 
674  return ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS);
675 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HMENU WINAPI LoadMenuW(HINSTANCE hInstance, LPCWSTR lpMenuName)
Definition: menu.c:1407
NTSYSAPI NTSTATUS NTAPI ZwCallbackReturn(_In_ PVOID Result, _In_ ULONG ResultLength, _In_ NTSTATUS Status)
_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:426
struct _LOADMENU_CALLBACK_ARGUMENTS * PLOADMENU_CALLBACK_ARGUMENTS
#define LRESULT
Definition: ole.h:14
LONG_PTR LRESULT
Definition: windef.h:209
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ User32LoadSysMenuTemplateForKernel()

NTSTATUS WINAPI User32LoadSysMenuTemplateForKernel ( PVOID  Arguments,
ULONG  ArgumentLength 
)

Definition at line 655 of file menu.c.

656 {
657  LRESULT Result = 0;
658 
659  // Use this for Menu Ole!!
660 
661  return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS));
662 }
NTSYSAPI NTSTATUS NTAPI ZwCallbackReturn(_In_ PVOID Result, _In_ ULONG ResultLength, _In_ NTSTATUS Status)
_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:426
LONG_PTR LRESULT
Definition: windef.h:209
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ 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)
}
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define WC_MENU
Definition: undocuser.h:9
smooth NULL
Definition: ftsmooth.c:416
#define COLOR_MENU
Definition: winuser.h:907
#define CS_SAVEBITS
Definition: winuser.h:652
#define CS_DBLCLKS
Definition: winuser.h:646
LRESULT WINAPI PopupMenuWndProcW(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: menu.c:305
#define IDC_ARROW
Definition: winuser.h:682

Definition at line 56 of file menu.c.