Partager via


_SetItemText( ) API Library Routine

Changes the displayed text for the specified menu item.

void _SetItemText(MENUID menuid, ITEMID itemid, char FAR *text)
MENUID menuid;            /* Menu identifier. */
ITEMID itemid;            /* Menu item identifier. */
char FAR *text;            /* Text. */

Remarks

The menu item can be either a menu title or a bar.

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

Example

The following example builds a menu with three items. It then changes the item text using _SetItemText( ).

Visual FoxPro Code

SET LIBRARY TO SETITEXT

C Code

#include <pro_ext.h>

FAR SetItemTextEx(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);

   _ActivateMenu(menuId);
   _Execute("WAIT WINDOW 'Original item text'");

   _SetItemText(menuId, _GetItemId(menuId, 0), 
      "This was the 1st item");
   _SetItemText(menuId, _GetItemId(menuId, 1), 
      "This was the 2nd item");
   _SetItemText(menuId, _GetItemId(menuId, 2), 
      "This was the 3rd item");

   _Execute("WAIT WINDOW 'New item text'");
   _DisposeMenu(menuId);
}

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

See Also

Reference

_GetItemId( ) API Library Routine

_GetItemText( ) API Library Routine

_SetItemCmdKey( ) API Library Routine

Other Resources

API Library Construction

Accessing the Visual FoxPro API