![]() | ![]() | 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_locationbysm_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-10 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.
- NULL Error returned by a
_get_strvariant. Callsm_menu_bar_errorto get the error code.
- -1 Error returned by a
_get_intvariant. Callsm_menu_bar_errorto 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*/
nint 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;
}
}
![]()
![]()
![]()
![]()