Important: The information in this document is obsolete and should not be used for new development.
GetNewMBar
Use theGetNewMBarfunction to read in the definition of a menu bar from an'MBAR'resource.
FUNCTION GetNewMBar (menuBarID: Integer): Handle;
menuBarID- The resource ID of an
'MBAR'resource that specifies the menus for a menu bar.DESCRIPTION
TheGetNewMBarfunction reads in the definition of a menu bar and its associated menus from an'MBAR'resource. The'MBAR'resource identifies the order of menus contained in its menu bar. For each menu, it also specifies the menu's resource ID. TheGetNewMBarfunction reads in each menu from the'MENU'resource with the resource ID specified in the'MBAR'resource.The
GetNewMBarfunction creates a menu list for the menu bar defined by the'MBAR'resource and returns a handle to the menu list. (If the resource isn't already in memory,GetNewMBarreads it into memory.) IfGetNewMBarcan't read the resource,GetNewMBarreturnsNIL.GetNewMBarusesGetMenuto read in each individual menu.After reading in menus from an
'MBAR'resource, useSetMenuBarto make the menu list created byGetNewMBarthe current menu list. Then useDrawMenuBarto update the menu bar.To release the memory occupied by the data structures associated with the menus in a menu list, use
DisposeMenufor each menu you created usingNewMenu; use the Resource Manager procedureReleaseResourcefor each menu you created usingGetMenuor if you read the resource in usingGetNewMBar. To release the memory occupied by a menu list, use the Memory Manager procedureDisposeHandle.SPECIAL CONSIDERATIONS
TheGetNewMBarfunction first saves the current menu list and then clears the current menu list and your application's menu color information table. It then creates a
new menu list. Before returning a handle to the new menu list, theGetNewMBarfunction restores the current menu list to the previously saved menu list, butGetNewMBardoes not restore the previous menu color information table. To save
and then restore your application's current menu color information table, call theGetMCInfofunction beforeGetNewMBarand call theSetMCInfoprocedure afterward.While you supply only the resource ID of an
'MBAR'resource to theGetNewMBarfunction, your application often needs to use the menu IDs defined in each of your menus''MENU'resources. Most Menu Manager routines require either a menu ID
or a handle to a menu record to perform operations on a specific menu. For menus in
the current menu list, you can use theGetMenuHandlefunction to get the handle to
a menu record of a menu with a given menu ID.SEE ALSO
For a description of the'MENU'resource, see "The Menu Resource" on page 3-154; for a sample'MENU'resource in Rez format, see Listing 3-2 on page 3-48. For a description of the'MBAR'resource, see "The Menu Bar Resource" on page 3-156; for a sample'MBAR'resource in Rez format, see Listing 3-4 on page 3-49. For information on the'mctb'resource, see "The Menu Color Information Table Resource" on page 3-157. For information about the Resource Manager, see Inside Macintosh: More Macintosh Toolbox.