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 / Adding and Deleting Menu Items


AppendResMenu

Use the AppendResMenu procedure to search all resource files open to your application for a given resource type and to append the names of any resources it finds to a specified menu. The specified menu must have been previously created using NewMenu, GetMenu, or GetNewMBar.

The AppendResMenu procedure is also available as the AddResMenu procedure.

PROCEDURE AppendResMenu (theMenu: MenuHandle; theType: ResType); 
theMenu
A handle to the menu record of the menu to which to append the names of any resources of a given type that AppendResMenu finds.
theType
A four-character code that identifies the resource type for which to search.
DESCRIPTION
The AppendResMenu procedure searches all resource files open to your application for resources of the type defined by the parameter theType. It appends the names of any resources it finds of the given type to the end of the specified menu. AppendResMenu appends the names of found resources in alphabetical order; it does not alphabetize items already in the menu. The AppendResMenu procedure does not add resources with names that begin with a period (.) or a percent sign (%) to the menu.

The AppendResMenu procedure assigns default characteristics to each menu item. Each appended menu item appears in the menu as an enabled item, without an icon or a mark, in the plain character style, and without a keyboard equivalent. To get the name or to change other characteristics of an item appended by AppendResMenu, use the Menu Manager routines described in "Getting and Setting the Appearance of Menu Items" beginning on page 3-132.

If you specify that AppendResMenu add resources of type 'DRVR' to your Apple menu, AppendResMenu adds the name (and icon) of each item in the Apple Menu Items folder to the menu.

If you specify that AppendResMenu append resources of type 'FONT' or 'FOND', the Menu Manager performs special processing for any resources it finds that have font numbers greater than $4000. If the script system associated with the font name is installed in the system, AppendResMenu stores information in the itemDefinitions array (in the itemIcon and itemCmd fields for that item) in the menu's menu record. This allows the Menu Manager to display the font name in the correct script.

SPECIAL CONSIDERATIONS
The AppendResMenu procedure calls the Resource Manager procedure SetResLoad (specifying TRUE in the load parameter) before returning. The AppendResMenu procedure reads the resource data of the resources it finds into memory. If your application does not want the Resource Manager to read resource data into memory when your application calls other routines that read resources, you need to call SetResLoad and specify FALSE in the load parameter after AppendResMenu returns.

SEE ALSO
Listing 3-15 on page 3-69 shows a sample that adds items from the Apple Menu Items folder to the Apple menu, and Listing 3-16 on page 3-70 shows a sample that adds font names to a menu. See Inside Macintosh: More Macintosh Toolbox for information on the Resource Manager.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996