Chapter 1 - Resource Manager
This chapter describes how to use the Resource Manager to read and write resources. You typically use resources to store the descriptions for user interface elements such as menus, windows, controls, dialog boxes, and icons. In addition, your application can store variable settings, such as the location of a window at the time the user closes the window, in a resource. When the user opens the document again, your application can read the information in the resource and restore the window to its previous location.This chapter begins with an introduction to basic concepts you should understand before you begin to use Resource Manager routines. The rest of the chapter describes how to
To use this chapter, you should be familiar with basic memory management on Macintosh computers and the Memory Manager. See the chapter "Introduction to Memory Management" in Inside Macintosh: Memory for details. You should also be familiar with the File Manager and the Standard File Package. See Inside Macintosh: Files for this information.
- create resources
- get a handle to a resource
- release and detach resources
- create and open a resource fork
- set the current resource file
- read and manipulate resources
- write resources
- read and write partial resources
For information on how to create resources using a high-level resource editor like the ResEdit application or a resource compiler like Rez, see ResEdit Reference and
Macintosh Programmer's Workshop Reference. (Rez is provided with Apple's Macintosh Programmer's Workshop [MPW]; both MPW and ResEdit are available through APDA.)To get information on the format of an individual resource type, see the documentation for the manager that interprets that resource. For example, to get the format of a
'MENU'
resource, refer to the chapter "Menu Manager" in Inside Macintosh: Macintosh Toolbox Essentials.
Chapter Contents
- Introduction to Resources
- The Data Fork and the Resource Fork
- Resource Types and Resource IDs
- The Resource Map
- Search Path for Resources
- About the Resource Manager
- Using the Resource Manager
- Creating a Resource
- Getting a Resource
- Releasing and Detaching Resources
- Opening a Resource Fork
- Opening an Application's Resource Fork
- Creating and Opening a Resource Fork
- Specifying the Current Resource File
- Reading and Manipulating Resources
- Writing Resources
- Working With Partial Resources
- Resource Manager Reference
- Data Structure, Resource Types, and Resource IDs
- The Resource Type
- Resource IDs
- Resource IDs of Owned Resources
- Resource Names
- Resource Manager Routines
- Initializing the Resource Manager
- Checking for Errors
- Creating an Empty Resource Fork
- Opening Resource Forks
- Getting and Setting the Current Resource File
- Reading Resources Into Memory
- Getting and Setting Resource Information
- Modifying Resources
- Writing to Resource Forks
- Getting a Unique Resource ID
- Counting and Listing Resource Types
- Getting Resource Sizes
- Disposing of Resources
- Closing Resource Forks
- Reading and Writing Partial Resources
- Getting and Setting Resource Fork Attributes
- Accessing Resource Entries in a Resource Map
- Resource File Format
- Resources in the System File
- User Information Resources
- Packages
- Function Key Resources
- Standard Icons
- ROM Resources
- Inserting the ROM Resource Map
- Overriding ROM Resources
- Summary of the Resource Manager
- Pascal Summary
- Constants
- Data Type
- Routines
- C Summary
Assembly-Language Summary
- Constants
- Data Type
- Routines
- Trap Macros
- Global Variables
- Result Codes