5 #ifndef _INC_cWndMenu_H
6 #define _INC_cWndMenu_H
11 #include "../WinAPI/WinTypes.h"
29 cWndMenuChild(HMENU hMenu,
int nPos)
30 : m_hMenu(::GetSubMenu(hMenu, nPos))
35 bool isValidHandle()
const
39 operator HMENU()
const
44 int GetMenuItemCount()
const
46 return ::GetMenuItemCount(m_hMenu);
48 HMENU GetSubMenuByPos(
int nPos=0)
const
52 return ::GetSubMenu(m_hMenu, nPos);
54 UINT GetMenuItemID(
int nPos)
const
56 return ::GetMenuItemID(m_hMenu, nPos);
58 bool EnableMenuItem(UINT nPos, UINT uCmd)
61 return ::EnableMenuItem(m_hMenu, nPos, uCmd);
63 bool CheckMenuItem(UINT nPos, UINT uCmd)
66 return ::CheckMenuItem(m_hMenu, nPos, uCmd);
68 bool EnableMenuCmd(UINT nCmd,
bool bActive)
70 return EnableMenuItem(nCmd, MF_BYCOMMAND | ((bActive) ? (MF_ENABLED) : (
MF_GREYED | MF_DISABLED)));
72 bool CheckMenuCmd(UINT nCmd,
bool bCheck)
74 return CheckMenuItem(nCmd, MF_BYCOMMAND | ((bCheck) ? (MF_CHECKED) : (MF_UNCHECKED)));
77 void SetMenuCmdText(UINT nCmd,
const GChar_t* pszText)
80 _GTN(::ModifyMenu)(m_hMenu, nCmd, MF_BYCOMMAND, nCmd, pszText);
83 bool RemoveMenuChild(UINT uPosition, UINT uFlags = MF_BYPOSITION)
86 return ::RemoveMenu(m_hMenu, uPosition, uFlags);
88 bool InsertMenuChild(UINT uPosition, UINT uFlags, UINT uIDNewItem,
const GChar_t* pszText)
92 return _GTN(::InsertMenu)( m_hMenu, uPosition, uFlags, uIDNewItem, pszText);
100 ::DestroyMenu(m_hMenu);
105 int TrackPopupMenu(UINT uFlags,
int x,
int y, HWND hWndParent)
110 return ::TrackPopupMenu(m_hMenu, uFlags, x, y, 0, hWndParent,
nullptr);
114 class cWndMenu :
public cWndMenuChild
120 cWndMenu(HMENU hMenu)
121 : cWndMenuChild(hMenu)
128 ::DestroyMenu(m_hMenu);
131 void AttachMenu(HMENU hMenu)
133 if (m_hMenu != hMenu)
142 typedef cWndMenuChild CMenu;
#define _GTN(c)
_WIN32 name has a A or W for UTF8 or UNICODE (like _FNF)
Definition: StrConst.h:28
#define MF_GREYED
alternate for spelling the 'A' version.
Definition: WinTypes.h:123
#define WINHANDLE_NULL
HWND, HPEN, etc are NOT OS Handles. like HWND_DESKTOP. like HANDLEPTR_NULL. This is a WINAPI void* ha...
Definition: cOSHandle.h:23
char GChar_t
My version of TCHAR, _TCHAR.
Definition: StrConst.h:26