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_location
by sm_mnscript_load. If you supplyNULL
, Panther searches in the most recently loaded script inmem_location
for 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.
NULL
Error returned by a_get_str
variant. Call sm_menu_bar_error to get the error code.
-1
Error returned by a_get_int
variant. Call sm_menu_bar_error to get the error code.
sm_menu_get_int
andsm_menu_get_str
returns the current setting of the specified property. Use the_int
variant for those properties that have an integer value—for example,MN_TEAR
; use the_str
variant for properties that take string values, such asMN_NAME
andMN_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;
}
}