Help Center

RemoveItemfunction

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

Windowsfunctiondoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

FUNCTION RemoveItem (BYVAL hMenu AS HMENU, BYVAL item AS LONG, BYVAL fByPosition AS BOOLEAN = FALSE) AS BOOLEAN
Also documented as DeleteItem — one description covers them all.

Parameters

NameDescription
hMenuHandle to the menu that contains the menu item.
itemThe identifier or position of the menu item to get delete. The meaning of this parameter depends on the value of fByPosition.
fByPositionThe 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