_ActivateMenu( ) API Library Routine

Displays the specified menu on the screen and immediately returns control to the calling routine.

void _ActivateMenu(MENUID menuid)
MENUID menuid            /* Menu identifier.

Remarks

If you detect the press of a mouse button or a keystroke on the menu, you can call _MenuInteract( ) to determine which menu item the user chose.

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. _ActivateMenu( ) displays the menu. This menu is non-modal in that interaction is not forced as with _MenuInteract( ). Rather, when the user makes a selection the _OnSelection( ) routine is called, the selected item is printed on the screen, and the menu is disposed of.

Visual FoxPro Code

SET LIBRARY TO ACTIMENU
WAIT WINDOW "Make selection from menu." NOWAIT
SUSPEND

C Code

#include <pro_ext.h>

static MENUID menuId;

void putLong(long n)
{
   Value val;

   val.ev_type = 'I';
   val.ev_long = n;
   val.ev_width = 10;

   _PutValue(&val);
}

FAR onSelection(long menuId, long itemId)
{
   _PutStr("\nitemId = "); putLong(itemId);
}

FAR deactivateMenu(ParamBlk FAR *parm)
{
   _DeActivateMenu(menuId);
   _DisposeMenu(menuId);
}

FAR activateMenu(ParamBlk FAR *parm)
{
   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);
   _OnSelection(menuId, -1, onSelection);
}

FoxInfo myFoxInfo[] = {
   {"ONLOAD", (FPFI) activateMenu, CALLONLOAD, ""},
   {"ONUNLOAD", (FPFI) deactivateMenu, CALLONUNLOAD, ""},
};

FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Reference

_DeActivateMenu( ) API Library Routine
_MenuId( ) API Library Routine
_NewItem( ) API Library Routine
_NewMenu( ) API Library Routine
_OnSelection( ) API Library Routine
_MenuInteract( ) API Library Routine
_OnSelection( ) API Library Routine

Concepts

API Library Routines A-Z

Other Resources

API Library Routines by Category