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


InsertResMenu

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

PROCEDURE InsertResMenu (theMenu: MenuHandle; theType: ResType;
                         afterItem: Integer); 
theMenu
A handle to the menu record of the menu to which to add the names of any resources of a given type that InsertResMenu finds.
theType
A four-character code that identifies the resource type for which to search.
afterItem
A number that indicates where in the menu to insert the names of any resources of the given type that InsertResMenu finds. Specify 0 in the afterItem parameter to insert the items before the first menu item; specify the item number of a menu item already in the menu to insert the items after the specified item number. If you specify a number greater than or equal to the last item in the menu, the items are inserted at the end of the menu.
DESCRIPTION
The InsertResMenu procedure searches all resource files open to your application for resources of the type defined by the parameter theType. It inserts the names of any resources it finds of the given type at the specified location in the specified menu. InsertResMenu adds the names of found resources in alphabetical order; it does not alphabetize items already in the menu.

The InsertResMenu procedure does not add resources with names that begin with a period (.) or a percent sign (%) to the menu.

The InsertResMenu 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 InsertResMenu, use the Menu Manager routines described in the next section, "Getting and Setting the Appearance of Menu Items."

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

If you specify that InsertResMenu add 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 associated with the font name is currently active, InsertResMenu stores information in the itemDefinitions array (in the itemIcon and itemCmd fields for that item) in the menu's menu record that allows the Menu Manager to display the font name in the correct script.

SPECIAL CONSIDERATIONS
The InsertResMenu procedure calls the Resource Manager procedure SetResLoad (specifying TRUE in the load parameter) before returning. The InsertResMenu 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 InsertResMenu returns.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996