Important: The information in this document is obsolete and should not be used for new development.
GetNewMBar
Use theGetNewMBar
function 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
TheGetNewMBar
function 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. TheGetNewMBar
function reads in each menu from the'MENU'
resource with the resource ID specified in the'MBAR'
resource.The
GetNewMBar
function 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,GetNewMBar
reads it into memory.) IfGetNewMBar
can't read the resource,GetNewMBar
returnsNIL
.GetNewMBar
usesGetMenu
to read in each individual menu.After reading in menus from an
'MBAR'
resource, useSetMenuBar
to make the menu list created byGetNewMBar
the current menu list. Then useDrawMenuBar
to update the menu bar.To release the memory occupied by the data structures associated with the menus in a menu list, use
DisposeMenu
for each menu you created usingNewMenu
; use the Resource Manager procedureReleaseResource
for each menu you created usingGetMenu
or if you read the resource in usingGetNewMBar
. To release the memory occupied by a menu list, use the Memory Manager procedureDisposeHandle
.SPECIAL CONSIDERATIONS
TheGetNewMBar
function 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, theGetNewMBar
function restores the current menu list to the previously saved menu list, butGetNewMBar
does not restore the previous menu color information table. To save
and then restore your application's current menu color information table, call theGetMCInfo
function beforeGetNewMBar
and call theSetMCInfo
procedure afterward.While you supply only the resource ID of an
'MBAR'
resource to theGetNewMBar
function, 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 theGetMenuHandle
function 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.