MiniGUI API Reference (MiniGUI-Processes)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Data Structures | Typedefs | Functions
Menu operations

Data Structures

struct  _MENUITEMINFO
 

Typedefs

typedef struct _MENUITEMINFO MENUITEMINFO
 

Functions

MG_EXPORT HMENU GUIAPI CreateMenu (void)
 Creates an empty menu. More...
 
MG_EXPORT HMENU GUIAPI CreatePopupMenu (PMENUITEMINFO pmii)
 Creates a drop-down menu or submenu. More...
 
MG_EXPORT HMENU GUIAPI CreateSystemMenu (HWND hwnd, DWORD dwStyle)
 Creates a system menu. More...
 
MG_EXPORT int GUIAPI InsertMenuItem (HMENU hmnu, LINT item, UINT flag, PMENUITEMINFO pmii)
 Inserts a new menu item at the specified position in a menu. More...
 
MG_EXPORT int GUIAPI RemoveMenu (HMENU hmnu, LINT item, UINT flag)
 Deletes a menu item or detaches a submenu from the specified menu. More...
 
MG_EXPORT int GUIAPI DeleteMenu (HMENU hmnu, LINT item, UINT flag)
 Deletes an item from the specified menu. More...
 
MG_EXPORT int GUIAPI DestroyMenu (HMENU hmnu)
 Destroys the specified menu and frees any memory that the menu occupies. More...
 
MG_EXPORT int GUIAPI IsMenu (HMENU hmnu)
 Determine whether a handle is a menu handle. More...
 
MG_EXPORT HMENU GUIAPI SetMenu (HWND hwnd, HMENU hmnu)
 Assigns a new menu to the specified main window. More...
 
MG_EXPORT HMENU GUIAPI GetMenu (HWND hwnd)
 Retrieve the handle to the menu assigned to the given main window. More...
 
MG_EXPORT void GUIAPI DrawMenuBar (HWND hwnd)
 Redraws the menu bar of the specified main window. More...
 
MG_EXPORT int GUIAPI TrackMenuBar (HWND hwnd, int pos)
 Displays the specified submenu. More...
 
MG_EXPORT int GUIAPI TrackPopupMenu (HMENU hmnu, UINT uFlags, int x, int y, HWND hwnd)
 Displays and tracks a popup menu. More...
 
MG_EXPORT HMENU GUIAPI GetMenuBarItemRect (HWND hwnd, int pos, RECT *prc)
 Retrieve the rect of a menu bar item. More...
 
MG_EXPORT BOOL GUIAPI HiliteMenuBarItem (HWND hwnd, int pos, UINT flag)
 Draws the specified menubar item with 3D effect. More...
 
MG_EXPORT int GUIAPI GetMenuItemCount (HMENU hmnu)
 Determine the number of items in a menu. More...
 
MG_EXPORT LINT GUIAPI GetMenuItemID (HMENU hmnu, int pos)
 Retrieve the menu item identifier of a menu item at specified position in a menu. More...
 
MG_EXPORT int GUIAPI GetMenuItemInfo (HMENU hmnu, LINT item, UINT flag, PMENUITEMINFO pmii)
 Retrieve information about a menu item. More...
 
MG_EXPORT HMENU GUIAPI GetPopupSubMenu (HMENU hpppmnu)
 Retrieve the submenu of the specified popup menu. More...
 
MG_EXPORT HMENU GUIAPI StripPopupHead (HMENU hpppmnu)
 Strips the title of the popup menu. More...
 
MG_EXPORT HMENU GUIAPI GetSubMenu (HMENU hmnu, int pos)
 Retrieve the handle to the submenu activated by the specified menu item. More...
 
MG_EXPORT HMENU GUIAPI GetSystemMenu (HWND hwnd, BOOL flag)
 Allows the application to access the window menu (also known as the system menu) for copying and modifying. More...
 
MG_EXPORT UINT GUIAPI EnableMenuItem (HMENU hmnu, LINT item, UINT flag)
 Enables, disables, or grays the specified menu item. More...
 
MG_EXPORT int GUIAPI CheckMenuRadioItem (HMENU hmnu, LINT first, LINT last, LINT checkitem, UINT flag)
 Check a specified menu item and makes it a radio item. More...
 
MG_EXPORT int GUIAPI SetMenuItemBitmaps (HMENU hmnu, LINT item, UINT flag, PBITMAP hBmpUnchecked, PBITMAP hBmpChecked)
 Associates the specified bitmap with a menu item. More...
 
MG_EXPORT int GUIAPI SetMenuItemInfo (HMENU hmnu, LINT item, UINT flag, PMENUITEMINFO pmii)
 Changes information about a menu item. More...
 

Detailed Description

Typedef Documentation

◆ MENUITEMINFO

typedef struct _MENUITEMINFO MENUITEMINFO

Structure defines a menu item

Function Documentation

◆ CheckMenuRadioItem()

LINT GUIAPI CheckMenuRadioItem ( HMENU  hmnu,
LINT  first,
LINT  last,
LINT  checkitem,
UINT  flag 
)

Check a specified menu item and makes it a radio item.

This function checks a specified menu item and makes it a radio item. At the same time, the function unchecks all other menu items in the associated group and clears the radio-item type flag for those items.

Parameters
hmnuThe handle to the menu.
firstThe position of the first item in the group.
lastThe position of the last item in the group.
checkitemThe position of the menu item to check.
flagIndicates the position base, can be one of the following values:
  • MF_BYCOMMAND
    The position value item is based on the command identifier.
  • MF_BYPOSITION
    The position value item is based on the position in the menu.
Returns
The function returns 0 for success, non-zero for failure.
Note
The type of first, last, checkitem changed from int to LINT since v3.2.
See also
SetMenuItemInfo, MENUITEMINFO

◆ CreateMenu()

HMENU GUIAPI CreateMenu ( void  )

Creates an empty menu.

This function creates a menu. The menu is initially empty, but it can be filled with menu items by using the InsertMenuItem functions.

Returns
The handle to the menu, zero when error.
See also
InsertMenuItem

◆ CreatePopupMenu()

HMENU GUIAPI CreatePopupMenu ( PMENUITEMINFO  pmii)

Creates a drop-down menu or submenu.

This function creates a drop-down menu or submenu. The menu is initially empty. You can insert or append menu items by using the InsertMenuItem function.

Parameters
pmiiMenu item information used to create the popup menu.
Returns
The handle to the popup menu.
See also
InsertMenuItem, MENUITEMINFO

◆ CreateSystemMenu()

HMENU GUIAPI CreateSystemMenu ( HWND  hwnd,
DWORD  dwStyle 
)

Creates a system menu.

This function creates a system menu for the main window specified by hwnd.

Parameters
hwndThe handle to the main window.
dwStyleThe style of the main window.
Returns
The handle to the system menu.
See also
CreateMenu, CreatePopupMenu

◆ DeleteMenu()

int GUIAPI DeleteMenu ( HMENU  hmnu,
LINT  item,
UINT  flag 
)

Deletes an item from the specified menu.

This function deletes an item from the specified menu hmnu. Either the item is a normal menu item or a submenu, this function will delete the item.

Parameters
hmnuThe handle to the menu.
itemThe position of the menu item or submenu.
flagIndicates the position base, can be one of the following values:
  • MF_BYCOMMAND
    The position value item is based on the command identifier.
  • MF_BYPOSITION
    The position value item is based on the position in the menu.
Returns
The function returns 0 for success, non-zero for failure.
Return values
ERR_INVALID_HANDLEhmnu is not a handle to menu.
ERR_INVALID_HMENUhmnu is an invalid menu.
Note
The type of item changed from int to LINT since v3.2.
See also
InsertMenuItem, RemoveMenu

◆ DestroyMenu()

int GUIAPI DestroyMenu ( HMENU  hmnu)

Destroys the specified menu and frees any memory that the menu occupies.

This function destroys the specified menu hmnu and frees any memory that the menu occupies.

Parameters
hmnuThe handle to the menu.
Returns
The function returns 0 for success, non-zero for failure.
Return values
ERR_INVALID_HANDLEhmnu is not a handle to menu.
See also
RemoveMenu, DeleteMenu

◆ DrawMenuBar()

void GUIAPI DrawMenuBar ( HWND  hwnd)

Redraws the menu bar of the specified main window.

This function redraws the menu bar of the specified main window. If the menu bar changes after the system has created the window, this function must be called to draw the changed menu bar.

Parameters
hwndThe handle to the main window.
See also
TrackMenuBar

◆ EnableMenuItem()

UINT GUIAPI EnableMenuItem ( HMENU  hmnu,
LINT  item,
UINT  flag 
)

Enables, disables, or grays the specified menu item.

This function enables, disables, or grays the specified menu item.

Parameters
hmnu[in] Handle to the menu.
item[in] Specifies the menu item or submenu to be enabled, disabled, or grayed, as determined by the flag parameter. This parameter specifies an item in a menu bar, menu or submenu.
flag[in] Controls the interpretation of the item parameter and indicates whether the menu item is enabled, disabled, or grayed. This parameter must be a combination of either MF_BYPOSITION or MF_BYCOMMAND.
Returns
The return value specifies the previous state of the menu item. If the menu item does not exist, the return value is -1.
Note
The type of item changed from int to LINT since v3.2.
See also
GetMenuItemInfo

◆ GetMenu()

HMENU GUIAPI GetMenu ( HWND  hwnd)

Retrieve the handle to the menu assigned to the given main window.

This function retrieves the handle to the menu assigned to the given main window hwnd.

Parameters
hwndThe handle to the main window.
Returns
The handle to the menu of the window.
See also
SetMenu

◆ GetMenuBarItemRect()

HMENU GUIAPI GetMenuBarItemRect ( HWND  hwnd,
int  pos,
RECT prc 
)

Retrieve the rect of a menu bar item.

This function retrieves the rect of the menu bar item specified by the parameter pos.

Parameters
hwndThe handle to the main window.
posThe position of the item. The position value of the first item is 0.
prcThe pointer to a RECT object, which will receive the rectangle.
Returns
The function returns the handle to the menu bar if success, otherwise returns 0.
See also
TrackMenuBar

◆ GetMenuItemCount()

int GUIAPI GetMenuItemCount ( HMENU  hmnu)

Determine the number of items in a menu.

This function determines the number of items in the specified menu hmnu.

Parameters
hmnuThe handle to the menu.
Returns
The number of the items in the menu.
See also
GetMenuItemInfo

◆ GetMenuItemID()

LINT GUIAPI GetMenuItemID ( HMENU  hmnu,
int  pos 
)

Retrieve the menu item identifier of a menu item at specified position in a menu.

This function retrieves the menu item identifier of a menu item at the specified position pos in the specified menu hmnu.

Parameters
hmnuThe handle to the menu.
posThe position of the menu item. The position value of the first item is 0.
Returns
The identifier of the items in the menu.
Note
The type of return value changed from int to LINT since v3.2.
See also
GetMenuItemInfo

◆ GetMenuItemInfo()

int GUIAPI GetMenuItemInfo ( HMENU  hmnu,
LINT  item,
UINT  flag,
PMENUITEMINFO  pmii 
)

Retrieve information about a menu item.

This function retrieves information about a menu item, and returns the information via pmii.

Parameters
hmnu[in] Handle to the menu that contains the menu item.
itemThe position of the menu item or submenu.
flagIndicates the position base, can be one of the following values:
  • MF_BYCOMMAND
    The position value item is based on the command identifier.
  • MF_BYPOSITION
    The position value item is based on the position in the menu.
pmii[in, out] Pointer to a MENUITEMINFO structure that specifies the information to retrieve and receive information about the menu item.
Returns
The function returns 0 for success, non-zero for failure.
Note
The type of item changed from int to LINT since v3.2.
See also
SetMenuItemInfo, MENUITEMINFO

◆ GetPopupSubMenu()

HMENU GUIAPI GetPopupSubMenu ( HMENU  hpppmnu)

Retrieve the submenu of the specified popup menu.

This function retrieves the submenu of the specified popup menu.

Parameters
hpppmnuThe handle to the popup menu.
Returns
The handle to the submenu of the popup menu.
See also
CreatePopupMenu

◆ GetSubMenu()

HMENU GUIAPI GetSubMenu ( HMENU  hmnu,
int  pos 
)

Retrieve the handle to the submenu activated by the specified menu item.

This function retrieves the handle to the drop-down menu or submenu activated by the specified menu item.

Parameters
hmnuThe handle to the menu.
posThe position of the menu item. The position value of the first item is 0.
Returns
The handle to the submenu; 0 if the menu item can not activate a submenu.
See also
GetPopupSubMenu

◆ GetSystemMenu()

HMENU GUIAPI GetSystemMenu ( HWND  hwnd,
BOOL  flag 
)

Allows the application to access the window menu (also known as the system menu) for copying and modifying.

This function returns the handle to the system menu of the main window. This allows the application to access the window menu (also known as the system menu) for copying and modifying.

Parameters
hwndThe handle to the main window.
flagIgnored currently; reserved for future use.
Returns
The handle to the system menu; 0 if the main window has not a system menu.
See also
GetMenu, SetMenu

◆ HiliteMenuBarItem()

BOOL GUIAPI HiliteMenuBarItem ( HWND  hwnd,
int  pos,
UINT  flag 
)

Draws the specified menubar item with 3D effect.

This function draws the specified menubar item with 3D effect.

Parameters
hwndThe handle to the main window.
posThe position of the item. The position value of the first item is 0.
flagThe drawing flag, can be one of the following values:
  • LFRDR_MENU_STATE_HILITE
    hilite item.
  • LFRDR_MENU_STATE_NORMAL
    normal item.
  • LFRDR_MENU_STATE_DISABLED
    disabled item.
Returns
TRUE on success, otherwise FALSE.
See also
TrackMenuBar

◆ InsertMenuItem()

int GUIAPI InsertMenuItem ( HMENU  hmnu,
LINT  item,
UINT  flag,
PMENUITEMINFO  pmii 
)

Inserts a new menu item at the specified position in a menu.

This function inserts a new menu item specified by pmmi at the specified position (determined by item and flag) in the menu hmnu.

Parameters
hmnuThe handle to the menu.
itemThe insertion position.
flagIndicates the position base, can be one of the following values:
  • MF_BYCOMMAND
    The position value item is based on the command identifier. The new menu item will insert bellow the item whose id is item.
  • MF_BYPOSITION
    The position value item is based on the position in the menu.
pmiiMenu item information used to create the popup menu.
Returns
The function returns 0 for success, non-zero for failure.
Return values
ERR_INVALID_HANDLEhmnu is not a handle to menu.
ERR_RES_ALLOCATIONCan not allocate new menu item.
ERR_INVALID_HMENUhmnu is an invalid menu.
Note
The type of item changed from int to LINT since v3.2.
See also
RemoveMenu, MENUITEMINFO

◆ IsMenu()

int GUIAPI IsMenu ( HMENU  hmnu)

Determine whether a handle is a menu handle.

This function determines whether the handle specified by hmnu is a menu handle.

Parameters
hmnuThe handle to a menu.
Returns
The function returns 0 for none menu handle, otherwise the type of the menu.
See also
CreateMenu

◆ RemoveMenu()

int GUIAPI RemoveMenu ( HMENU  hmnu,
LINT  item,
UINT  flag 
)

Deletes a menu item or detaches a submenu from the specified menu.

This function deletes a menu item or detaches a submenu from the specified menu hmnu. If the item is a normal menu item, the function will delete the item. If the item is a submenu, the function will detache the submenu for the menu, but not delete the submenu.

Parameters
hmnuThe handle to the menu.
itemThe position of the menu item or submenu.
flagIndicates the position base, can be one of the following values:
  • MF_BYCOMMAND
    The position value item is based on the command identifier.
  • MF_BYPOSITION
    The position value item is based on the position in the menu.
Returns
The function returns 0 for success, non-zero for failure.
Return values
ERR_INVALID_HANDLEhmnu is not a handle to menu.
ERR_INVALID_HMENUhmnu is an invalid menu.
Note
The type of item changed from int to LINT since v3.2.
See also
InsertMenuItem, DeleteMenu

◆ SetMenu()

HMENU GUIAPI SetMenu ( HWND  hwnd,
HMENU  hmnu 
)

Assigns a new menu to the specified main window.

This functionn assigns the specified menu hmnu to the main window specified by hwnd.

Parameters
hwndThe handle to the main window.
hmnuThe handle to the new menu.
Returns
The handle to the old menu of the window.
See also
GetMenu

◆ SetMenuItemBitmaps()

int GUIAPI SetMenuItemBitmaps ( HMENU  hmnu,
LINT  item,
UINT  flag,
PBITMAP  hBmpUnchecked,
PBITMAP  hBmpChecked 
)

Associates the specified bitmap with a menu item.

This function associates the specified bitmap with a menu item. Whether the menu item is checked or unchecked, the system displays the appropriate bitmap next to the menu item.

Parameters
hmnuThe handle to the menu.
itemThe position of the menu item.
flagIndicates the position base, can be one of the following values:
  • MF_BYCOMMAND
    The position value item is based on the command identifier.
  • MF_BYPOSITION
    The position value item is based on the position in the menu.
hBmpUncheckedThe pointer to the unchecked BITMAP object.
hBmpCheckedThe pointer to the checked BITMAP object.
Returns
The function returns 0 for success, non-zero for failure.
Note
The type of item changed from int to LINT since v3.2.
See also
SetMenuItemInfo, MENUITEMINFO

◆ SetMenuItemInfo()

int GUIAPI SetMenuItemInfo ( HMENU  hmnu,
LINT  item,
UINT  flag,
PMENUITEMINFO  pmii 
)

Changes information about a menu item.

This function changes information about the specified menu item.

Parameters
hmnu[in] Handle to the menu that contains the menu item.
item[in] Specifies the identifier or position of the menu item to change. The meaning of this parameter depends on the value of flag.
flagIndicates the position base, can be one of the following values:
  • MF_BYCOMMAND
    The position value item is based on the command identifier.
  • MF_BYPOSITION
    The position value item is based on the position in the menu.
pmiiThe pointer to a MENUITEMINFO structure contains the information.
Returns
The function returns 0 for success, non-zero for failure.
Note
The type of item changed from int to LINT since v3.2.
See also
GetMenuItemInfo, MENUITEMINFO

◆ StripPopupHead()

HMENU GUIAPI StripPopupHead ( HMENU  hpppmnu)

Strips the title of the popup menu.

This function strips the title of the popup menu hpppmnu.

Parameters
hpppmnuThe handle to the popup menu.
Returns
The handle to the submenu whose title has been stripped.
See also
GetPopupSubMenu

◆ TrackMenuBar()

int GUIAPI TrackMenuBar ( HWND  hwnd,
int  pos 
)

Displays the specified submenu.

This function displays the specified submenu in the menu bar of the specified main window hwnd.

Parameters
hwndThe handle to the main window.
posThe position of the submenu. The position value of the first submenu is 0.
Returns
The function returns 0 for success, non-zero for failure.
See also
TrackPopupMenu, CreateMenu

◆ TrackPopupMenu()

int GUIAPI TrackPopupMenu ( HMENU  hmnu,
UINT  uFlags,
int  x,
int  y,
HWND  hwnd 
)

Displays and tracks a popup menu.

This function displays a shortcut menu at the specified location and tracks the selection of items on the menu. The shortcut menu can appear anywhere on the screen.

Parameters
hmnuThe handle to the popup menu.
uFlagsThe tracking flags, can be OR'ed value of the following values:
  • TPM_LEFTALIGN
    Horz alignement is left.
  • TPM_CENTERALIGN
    Horz alignement is center.
  • TPM_RIGHTALIGN
    Horz alignement is right.
  • TPM_TOPALIGN
    Vert alignement is top.
  • TPM_VCENTERALIGN
    Vert alignement is center.
  • TPM_BOTTOMALIGN
    Vert alignement is bottom.
  • TPM_DESTROY
    Destroys the popup menu after finishing tracking.
  • TPM_SYSCMD
    Send an MSG_SYSCOMMAND message to the window when the use select a menu item.
xThe x coordinate of the position of the popup menu.
yThe y coordinate of the position of the popup menu.
hwndThe handle to the window which will receive the MSG_COMMAND or MSG_SYSCOMMAND message.
Returns
The function returns 0 for success, non-zero for failure.
See also
TrackMenuBar, CreatePopupMenu