_MenuId( ) (Rutina de biblioteca API)

Devuelve el identificador del menú que corresponde al literal definido por el sistema para el menú del sistema o el título del menú.

MENUID _MenuId(long literal)
long literal;                  /* System-defined literal. */

Observaciones

Los literales se definen en el archivo de inclusión PRO_EXT.H de la API.

Para obtener más información acerca de cómo crear una biblioteca API e integrarla con Visual FoxPro, vea Acceso a la API de Visual FoxPro.

Ejemplo

El ejemplo siguiente agrega un título de menú al menú del sistema. A continuación, agrega un menú desplegable con dos elementos. _MenuId( ) se emplea para obtener el MENUID del menú del sistema.

Código Visual FoxPro

SET LIBRARY TO MENUID  

Código C

#include <pro_ext.h>

MENUID SysMenuId;
MENUID PopupId;
ITEMID PadId;

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);
}

void FAR StartUp()
{
   ITEMID Bar1Id;
   ITEMID Bar2Id;
   int Error;

   // Add new menu title to SYSMENU.
   SysMenuId = _MenuId(_SYSMENU);
   PadId = _GetNewItemId(SysMenuId);

   if (_NewItem(SysMenuId, PadId, _LASTITEM, "\\<Added menu title"))
   {
      _Error(623); /* "Menu item cannot be defined." */
   }

   // Define menu.
   PopupId = _GetNewMenuId();

   if (Error = _NewMenu(MPOPUP, PopupId))
   {
      _Error(-Error);
   }
   Bar1Id = _GetNewItemId(PopupId);

   // WARNING: Call _NewItem() before another _GetNewItemId().
   if (_NewItem(PopupId, Bar1Id, _LASTITEM, "\\<1st item"))
   {
      _Error(623); /* "Menu item cannot be defined." */
   }
   Bar2Id = _GetNewItemId(PopupId);

   if (_NewItem(PopupId, Bar2Id, _LASTITEM, "\\<2nd item"))
   {
      _Error(623); /* "Menu item cannot be defined." */
   }

   // Attach menu to menu title
   _SetItemSubMenu(SysMenuId, PadId, PopupId);

   // Set up selection action.
   _OnSelection(PopupId, -1, onSelection);
}

void FAR ShutDown()
{
   _DisposeItem(SysMenuId, PadId);
   _DisposeMenu(PopupId);
}

FoxInfo myFoxInfo[] = {
   {"STARTUP",   (FPFI) StartUp,   CALLONLOAD,""},
   {"SHUTDOWN",   (FPFI) ShutDown,   CALLONUNLOAD, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

Vea también

SYS(1500) - Activar un elemento de menú del sistema | _GetNewMenuId( ) (Rutina de biblioteca API) | Nombres de menús del sistema | _MenuInteract( ) (Rutina de biblioteca API)