Important: The information in this document is obsolete and should not be used for new development.
NewMenu
You can use theNewMenufunction 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 theGetMenuorGetNewMBarfunction 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
TheNewMenufunction 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). TheNewMenufunction does not insert the newly created menu into the current menu list.After creating a menu with
NewMenu, useAppendMenu,InsertMenuItem,AppendResMenu, orInsertResMenuto add menu items to the menu. To add a menu created byNewMenuto the current menu list, use theInsertMenuprocedure. To update the menu bar with any new menu titles, use theDrawMenuBarprocedure.SPECIAL CONSIDERATIONS
To release the memory associated with a menu that you created usingNewMenu, first
callDeleteMenuto 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 callDisposeMenuto dispose of the menu's menu record. After disposing of a menu, useDrawMenuBarto update the menu bar.If the
NewMenufunction is unable to create the menu record, it returnsNILas its function result.SEE ALSO
For information on how to add items to a menu, see the description ofAppendMenuon page 3-126,InsertMenuItemon page 3-128,AppendResMenuon page 3-130, andInsertResMenuon page 3-131. For information onInsertMenu, see page 3-110. To dispose of a menu, see the description ofDeleteMenuon page 3-111 andDisposeMenuon page 3-142.