_DisposeItem( ) API Library Routine

Releases from memory the specified menu item, and frees all memory storage associated with this item.

void _DisposeItem(MENUID menuid, ITEMID itemid)
MENUID menuid;            /* Menu identifier. */
ITEMID itemid;            /* Menu item identifier. */

_DisposeItem( ) doesn't release any submenus that are associated with the item.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

The following example creates a menu with three items and then uses _DisposeItem( ) to remove two of the items.

Visual FoxPro Code


C Code

#include <pro_ext.h>

FAR DisposeItemEx(ParamBlk FAR *parm)
   MENUID menuId;
   ITEMID itemId;
   Point loc;

   menuId = _GetNewMenuId();
   _NewMenu(MPOPUP, menuId);

   itemId = _GetNewItemId(menuId);
   _NewItem(menuId, itemId, -2, "\\<1st item");

   itemId = _GetNewItemId(menuId);
   _NewItem(menuId, itemId, -2, "\\<2nd item");

   itemId = _GetNewItemId(menuId);
   _NewItem(menuId, itemId, -2, "\\<3rd item");

   loc.v = 10; loc.h = 20;
   _SetMenuPoint(menuId, loc);

   _Execute("WAIT WINDOW 'Menu has three items'");

   _DisposeItem(menuId, _GetItemId(menuId, 1));
   _Execute("WAIT WINDOW 'Menu has two items'");

   _DisposeItem(menuId, _GetItemId(menuId, 0));
   _Execute("WAIT WINDOW 'Menu has one item'");

FoxInfo myFoxInfo[] = {
   {"ONLOAD", (FPFI) DisposeItemEx, CALLONLOAD, ""},
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo

Community Additions