![]() | Programming Guide | ![]() |
Gets a menu's property
int sm_menu_get_int(int mem_location, char *script, char *menu, int prop);char *sm_menu_get_str(int mem_location, char *script, char *menu, int prop);
mem_location- The menu's memory location, one of the following constants:
MNL_APPLIC
MNL_SCREEN
MNL_FIELDscript- The name of a memory-resident script that contains the menu. The script must already be loaded into memory at
mem_locationby sm_mnscript_load. If you supplyNULL, Panther searches in the most recently loaded script inmem_locationfor the specified menu.menu- The menu's name. If you supply
NULL, Panther uses the first menu inscript.prop- The property to get. Table 5-12 lists the properties that you can get and their constants.
- · A pointer to the property's current value, returned either as an integer or as a pointer to a string value.
NULLError returned by a_get_strvariant. Call sm_menu_bar_error to get the error code.
-1Error returned by a_get_intvariant. Call sm_menu_bar_error to get the error code.
sm_menu_get_intandsm_menu_get_strreturns the current setting of the specified property. Use the_intvariant for those properties that have an integer value—for example,MN_TEAR; use the_strvariant for properties that take string values, such asMN_NAMEandMN_TITLE.
/*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;
}
}
![]()
![]()
![]()
![]()