Condividi tramite


_SetMenuPoint( ) API Library Routine

Specifies the screen position of the upper-left corner, loc, of a menu.

void _SetMenuPoint(MENUID menuid, Point loc)
MENUID menuid;            /* Menu identifier. */
Point loc;                  /* Position of upper-left corner
 of the menu. */

Remarks

Normally, a menu is automatically positioned based upon its size and how the user invoked it. This routine is provided to override automatic positioning.

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

Example

A menu is created and then activated at three different screen positions specified by _SetMenuPoint( ).

Visual FoxPro Code

SET LIBRARY TO SETMNPNT

C Code

#include <pro_ext.h>

FAR SetMenuPointEx(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);
   _MenuInteract(&menuId, &itemId);

   loc.v = 15; loc.h = 30;
   _SetMenuPoint(menuId, loc);
   _MenuInteract(&menuId, &itemId);

   loc.v = 20; loc.h = 40;
   _SetMenuPoint(menuId, loc);
   _MenuInteract(&menuId, &itemId);

   _DisposeMenu(menuId);
}

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

See Also

_NewMenu( ) API Library Routine | Accessing the Visual FoxPro API | _SetItemCmdKey( ) API Library Routine | _SetMenuPointP( ) API Library Routine