uLib  User mode C/C++ extended API library for Win32 programmers.

Module Description

Additional menu APIs...

Macros

#define MIIM_ALL
 
#define AddMenuSeparator(hSubMenu)   AddMenuItem( hSubMenu, 999, NULL, (-1), 0, NULL, NULL )
 

Typedefs

typedef bool(__stdcall * PFnMenuItemAction) (HMENU hMenu, MENUITEMINFO *pInfo, PVOID Ctx)
 

Functions

HMENU LoadMenuEx (HMODULE hModule, CSTR Id, LANGID Language)
 
HMENU AddSubMenu (HMENU hMenu, UINT Index, CSTR Text, WORD Id=0, WORD State=0, PVOID Data=NULL, HBITMAP Image=NULL)
 
bool AddMenuItem (HMENU hMenu, UINT Index, CSTR Text, WORD cmdId, WORD State=0, PVOID Data=NULL, HBITMAP Image=NULL)
 
int GetMenuItemIdByName (HMENU hMenu, CSTR Name)
 
LPMENUITEMINFO GetMenuItemByName (HMENU hMenu, CSTR Name)
 
PVOID GetMenuItemData (HMENU hMenu, UINT Id)
 
bool SetMenuItemCheck (HMENU hMenu, UINT Id, bool Check)
 
UINT EnumerateMenuItems (HMENU hMenu, PFnMenuItemAction Action, PVOID Ctx)
 

Macro Definition Documentation

◆ MIIM_ALL

#define MIIM_ALL
Value:
( MIIM_STRING | MIIM_ID | MIIM_FTYPE | MIIM_STATE \
| MIIM_SUBMENU | MIIM_DATA | MIIM_BITMAP | MIIM_CHECKMARKS )

Combination of all valid MIIM_nnn flags.

Definition at line 1326 of file UtilFunc.h.

◆ AddMenuSeparator

#define AddMenuSeparator (   hSubMenu)    AddMenuItem( hSubMenu, 999, NULL, (-1), 0, NULL, NULL )

Definition at line 1366 of file UtilFunc.h.

Typedef Documentation

◆ PFnMenuItemAction

typedef bool(__stdcall * PFnMenuItemAction) (HMENU hMenu, MENUITEMINFO *pInfo, PVOID Ctx)

Action callback for EnumerateMenuItems().

Definition at line 1388 of file UtilFunc.h.

Function Documentation

◆ LoadMenuEx()

HMENU LoadMenuEx ( HMODULE  hModule,
CSTR  Id,
LANGID  Language 
)

LoadMenuEx loads an internationalized menu resource.
On error it returns null and GetLastError() has the cause.
If the menu resource doesn't exist the code is ERROR_INVALID_PARAMETER.

Definition at line 639 of file UserUtil.cpp.

◆ AddSubMenu()

HMENU AddSubMenu ( HMENU  hMenu,
UINT  Index,
CSTR  Text,
WORD  Id = 0,
WORD  State = 0,
PVOID  Data = NULL,
HBITMAP  Image = NULL 
)

Create a new popup menu and insert it in a given menu.

Parameters
hMenuThe menu to recieve a new submenu.
IndexSubmenu position in hMenu. Use UINT(-1) to append.
TextName of the new submenu.
Id[opt] Id of the new submenu.
State[opt] State flags (MFS_nnn).
Data[opt] Arbitrary data.
Image[opt] Bitmap to use. Must persist the executable lifetime.
Returns
Return the submenu handle, or NULL on failure.

Definition at line 718 of file UserUtil.cpp.

◆ AddMenuItem()

bool AddMenuItem ( HMENU  hMenu,
UINT  Index,
CSTR  Text,
WORD  cmdId,
WORD  State = 0,
PVOID  Data = NULL,
HBITMAP  Image = NULL 
)

Add a new menu item with optional paraphernalia to a given menu.

Parameters
hMenuThe menu to recieve a new item.
IndexItem position in hMenu. Use UINT(-1) to append.
TextName of the item.
cmdIdCommand id of the item.
State[opt] State flags (MFS_nnn).
Data[opt] Arbitrary data.
Image[opt] Bitmap to use. Must be persistent.
Returns
Return true on success, else false.

Definition at line 767 of file UserUtil.cpp.

◆ GetMenuItemIdByName()

int GetMenuItemIdByName ( HMENU  hMenu,
CSTR  Name 
)

Find menu command/id by it's name.
See also GetMenuItemByName().

Definition at line 673 of file UserUtil.cpp.

◆ GetMenuItemByName()

LPMENUITEMINFO GetMenuItemByName ( HMENU  hMenu,
CSTR  Name 
)

Find menu item info by it's name.

Definition at line 650 of file UserUtil.cpp.

◆ GetMenuItemData()

PVOID GetMenuItemData ( HMENU  hMenu,
UINT  Id 
)

Get menu item data, if any..
Return NULL if none.

Definition at line 681 of file UserUtil.cpp.

◆ SetMenuItemCheck()

bool SetMenuItemCheck ( HMENU  hMenu,
UINT  Id,
bool  Check 
)

Check/unckeck a menu item.

Definition at line 694 of file UserUtil.cpp.

◆ EnumerateMenuItems()

UINT EnumerateMenuItems ( HMENU  hMenu,
PFnMenuItemAction  Action,
PVOID  Ctx 
)

Enumerate the items in a menu..

Definition at line 806 of file UserUtil.cpp.