_SetItemCmdKey( ), API-Bibliotheksroutine

Legt sowohl die Tastenkombination für den angegebenen Menüeintrag als auch den angezeigten Text für die Tastenkombination fest.

void _SetItemCmdKey(MENUID menuid, ITEMID itemid, int key,
 char FAR *text)
MENUID menuid;            /* Menu identifier. */
ITEMID itemid;            /* Menu item identifier. */
int key;                     /* Shortcut key. */
char FAR *text;            /* Displayed text. */

Hinweise

Wenn Sie keine Tastenkombination anzeigen möchten, übergeben Sie für text einen Zeiger auf eine Null-Zeichenfolge. Wenn das System den Standardtext anzeigen soll, übergeben Sie (char FAR *)0.

Weitere Informationen zum Erstellen einer API-Bibliothek und ihrer Integration in Visual FoxPro finden Sie unter Zugreifen auf die Visual FoxPro-API.

Beispiel

Im folgenden Beispiel wird ein Menü mit drei Einträgen erstellt. Jedem Eintrag wird eine Tastenkombination zugewiesen.

Visual FoxPro-Code

SET LIBRARY TO SETICMDK

C-Code

#include <pro_ext.h>

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);
   _DisposeMenu(menuId);
}

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

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

   itemId = _GetNewItemId(menuId);
   _NewItem(menuId, itemId, -2, "\\<1st item");
   _SetItemCmdKey(menuId, itemId, altKey | 0x178, "Alt+1");

   itemId = _GetNewItemId(menuId);
   _NewItem(menuId, itemId, -2, "\\<2nd item");
   _SetItemCmdKey(menuId, itemId, altKey | 0x179, "Alt+2");

   itemId = _GetNewItemId(menuId);
   _NewItem(menuId, itemId, -2, "\\<3rd item");
   _SetItemCmdKey(menuId, itemId, altKey | 0x17a, "Alt+3");

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

   _ActivateMenu(menuId);
   _OnSelection(menuId, -1, onSelection);
}

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

Siehe auch

_GetItemCmdKey( ), API-Bibliotheksroutine | _GetItemId( ), API-Bibliotheksroutine | Zugreifen auf die Visual FoxPro-API | _SetItemSubMenu( ), API-Bibliotheksroutine | _SetItemText( ), API-Bibliotheksroutine