Programming Guide |
Sets a menu's properties
int sm_menu_change(int mem_location, char *script, char *menu, int prop, int intval, char *strval);
mem_location
- The menu's memory location, one of these constants:
MNL_ANY
MNL_APPLIC
MNL_SCREEN
MNL_FIELDIf set to
MNL_ANY
, Panther looks for the menu in all memory locations. If the menu is installed in more than one location, the call fails and returnsMN_ERR_LOCATION
.script
- The name of a memory-resident script that contains the menu to change. The script must already be loaded into memory at
mem_location
by sm_mnscript_load. If you supplyNULL
, Panther searches among the most recently loaded script inmem_location
for the specified menu.menu
- The menu to change. If set to
NULL
, Panther uses the first menu inscript
.prop
- The property to change. Table 5-11 lists properties that you can change and their constants.
intval
- The integer value to set for
prop
. Supply0
ifprop
takes a string value.strval
- The string value to set for
prop
. SupplyNULL
ifprop
takes an integer value.
C only
sm_menu_change
sets a menu property. Menu properties are derived from a memory-resident script. Becausesm_menu_change
changes the specified script, all instances of menus from this script get the requested property change.Specify the property to change through one of the constants in Table 5-11. Menu-specific properties begin with a prefix of
MN
. Properties that begin withMNI
set defaults for new items that are added to the menu at runtime. If you callsm_menu_change
to reset item property defaults, the changes only affect items that are added after this call; it leaves existing menu items unchanged. To reset item properties for individual items, call sm_mnitem_change.
/*enable and disable menu tear-offs*/
int ToggleTearOffs(void)
{
int errorCode;
switch
(sm_menu_get_int(MNL_SCREEN, "menucom", "main", MN_TEAR)
{
/*enable tear-offs */
case 0: sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 1, NULL);
break;
/*disable tear-offs */
case 1: sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 0, NULL);
break;
/* if error returned, find out why */
case -1:
errorCode = sm_menu_bar_error();
menuErrorHandler(errorCode);
break;
}
}