Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 1 - Resource Manager / Introduction to Resources

Resource Types and Resource IDs

You typically use resources to store structured data, such as icons and sounds, and descriptions of menus, controls, dialog boxes, and windows. When you create a resource, you assign it a resource type and resource ID. A resource type is a sequence of four characters that uniquely identifies a specific type of resource, and a resource ID identifies a specific resource of a given type by number. (You can also use a resource name instead of a resource ID to identify a resource of a given type. However, a resource ID is preferred because it's generally more convenient to generate unique numbers than unique names.)

For example, to create a description of a menu in a resource, you create a resource of type 'MENU' and give it a resource ID or resource name that differs from any other 'MENU' resources that you have defined. In general, resource numbers 128 through 32767 are available for your use, although the numbers you can use for some types of resources are more restricted. (See "Resource IDs" on page 1-42 for more information about restrictions on the resource IDs used with specific resource types.)

System software defines a number of standard resource types. Here are some examples:
'ALRT'Alert box
'CODE'Application code segment
'DITL'Item list in a dialog box or alert box
'DLOG'Dialog box
'ICN#'Large (32-by-32 pixel) black-and-white icon, with mask
'ICON'Large (32-by-32 pixel) black-and-white icon, without mask
'MBAR'Menu bar
'NFNT'Bitmapped font
'STR 'String
'STR#'String list
'movv'QuickTime movie
'snd 'Sound

You can use these resource types to define their corresponding elements (for example, use a 'WIND' resource to define a window). You can also create your own resource types if your application needs resources other than the standard resource types defined by the system software. See Table 1-2 on page 1-37 for a complete list of standard resource types.

The Resource Manager does not interpret the format of an individual resource type. When you request a resource of a particular type with a given resource ID, the Resource Manager looks for the specified resource and, if it finds it, reads the resource into memory and returns a handle to it.

Your application or other system software routines can use the Resource Manager to read resources into memory. For example, when you use the Window Manager to read a description of a window from a 'WIND' resource, the Window Manager uses the Resource Manager to read the resource into memory. Once the resource is in memory, the Window Manager interprets the resource's data and creates a window with the characteristics described by the resource.

System software stores certain resources for its own use in the System file's resource fork. Although many of these resources are used only by the system software, your application can use some of them if necessary. For example, the standard images for the I-beam and wristwatch cursors are stored as resources of type 'CURS' in the System file. Your application can use these resources to change the appearance of the cursor.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice