Important: The information in this document is obsolete and should not be used for new development.
NewMenu
You can use theNewMenu
function to create an empty menu with a specified title and menu ID. In most cases you should store information about your menus (such as their titles, items, and characteristics) in resources; use theGetMenu
orGetNewMBar
function to create menus from resource definitions.
FUNCTION NewMenu (menuID: Integer; menuTitle: Str255): MenuHandle;
menuID
- The menu ID of the menu. (Note that this is not the resource ID of a
'MENU'
resource.) The menu ID is a number that identifies the menu. Use positive menu IDs for menus belonging to your application. Use negative menu IDs for desk accessories (except for submenus of a desk accessory). Submenus must have menu IDs from 1 through 255. For submenus of an application, use menu IDs from 1 through 235; for submenus of a desk accessory, use menu IDs from 236 through 255. Apple reserves the menu ID of 0.menuTitle
- The title of the new menu. Note that in most cases you should store
the titles of menus in resources, so that your menu titles can be more easily localized.DESCRIPTION
TheNewMenu
function creates a menu with the specified title, assigns it the specified menu ID, creates a menu record for the menu, and returns a handle to the menu record. It sets up the menu record to use the standard menu definition procedure (and it reads the standard menu definition procedure into memory if it isn't already there). TheNewMenu
function does not insert the newly created menu into the current menu list.After creating a menu with
NewMenu
, useAppendMenu
,InsertMenuItem
,AppendResMenu
, orInsertResMenu
to add menu items to the menu. To add a menu created byNewMenu
to the current menu list, use theInsertMenu
procedure. To update the menu bar with any new menu titles, use theDrawMenuBar
procedure.SPECIAL CONSIDERATIONS
To release the memory associated with a menu that you created usingNewMenu
, first
callDeleteMenu
to remove the menu from the current menu list and to remove any entries for this menu in your application's menu color information table; then callDisposeMenu
to dispose of the menu's menu record. After disposing of a menu, useDrawMenuBar
to update the menu bar.If the
NewMenu
function is unable to create the menu record, it returnsNIL
as its function result.SEE ALSO
For information on how to add items to a menu, see the description ofAppendMenu
on page 3-126,InsertMenuItem
on page 3-128,AppendResMenu
on page 3-130, andInsertResMenu
on page 3-131. For information onInsertMenu
, see page 3-110. To dispose of a menu, see the description ofDeleteMenu
on page 3-111 andDisposeMenu
on page 3-142.