RemoveItemfunction
Deletes a menu item or detaches a submenu from the specified menu.
Syntax
FUNCTION RemoveItem (BYVAL hMenu AS HMENU, BYVAL item AS LONG, BYVAL fByPosition AS BOOLEAN = FALSE) AS BOOLEAN
DeleteItem — one description covers them all.Parameters
| Name | Description | |
|---|---|---|
hMenu | Handle to the menu that contains the menu item. | |
item | The identifier or position of the menu item to get delete. The meaning of this parameter depends on the value of fByPosition. | |
fByPosition | The meaning of item. If this parameter is FALSE, item is a menu item identifier. Otherwise, it is a menu item position, where position = 0 for the first position, position = 1 for the second, and so on. |
Return value
Returns TRUE if the function succeeds; FALSE otherwise.
Description
Deletes a menu item or detaches a submenu from the specified menu.
Remarks
To remove menus use always the position and to remove drop-down menus use the identifier.
Example
' ---------------------------------------------------------------------------------------- ' Remove by identifier: ' ---------------------------------------------------------------------------------------- CMenu.DeleteItem(hMenu, IDM_OPEN) ' Removes the menu item with the IDM_OPEN identifier CMenu.DeleteItem(hMenu, IDM_POPUP) ' Removes the popup menu with the IDM_POPUP identifier ' ---------------------------------------------------------------------------------------- ' Remove a menu by position ' ---------------------------------------------------------------------------------------- CMenu.DeleteItem(hMenu, 1, TRUE) ' Removes the second menu (zero-based position) ' ---------------------------------------------------------------------------------------- ' Remove an item by position ' ---------------------------------------------------------------------------------------- DIM hFoundMenu AS HMENU, itemPos AS LONG DIM bRes AS BOOLEAN = CMenu.FindItemPos(hMenu, IDM_EXIT, hFoundMenu, itemPos) IF bRes THEN CMenu.DeleteItem(hFoundMenu, itemPos, TRUE) ' ----------------------------------------------------------------------------------------
Reference
- Documented in Windows/WIndows Controls/CMenu Class.md
- Topic: About Menus