Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /
Chapter 3 - Menu Manager / Menu Manager Reference
Menu Manager Routines / Getting a Menu Bar Description From an 'MBAR' Resource


GetNewMBar

Use the GetNewMBar 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
The GetNewMBar 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. The GetNewMBar 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.) If GetNewMBar can't read the resource, GetNewMBar returns NIL. GetNewMBar uses GetMenu to read in each individual menu.

After reading in menus from an 'MBAR' resource, use SetMenuBar to make the menu list created by GetNewMBar the current menu list. Then use DrawMenuBar 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 using NewMenu; use the Resource Manager procedure ReleaseResource for each menu you created using GetMenu or if you read the resource in using GetNewMBar. To release the memory occupied by a menu list, use the Memory Manager procedure DisposeHandle.

SPECIAL CONSIDERATIONS
The GetNewMBar 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, the GetNewMBar function restores the current menu list to the previously saved menu list, but GetNewMBar does not restore the previous menu color information table. To save
and then restore your application's current menu color information table, call the GetMCInfo function before GetNewMBar and call the SetMCInfo procedure afterward.

While you supply only the resource ID of an 'MBAR' resource to the GetNewMBar 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 the GetMenuHandle 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.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996