Microsoft KB Archive/34351
Article ID: 34351
Article Last Modified on 11/21/2006
This article was previously published under Q34351
The following is a replacement for the "Creating Application Icons with ICN#" discussion on Pages 152, 153, 154, 155, 156, and 157 of the "Microsoft QuickBasic for Apple Macintosh: User's Guide." The discussion in the manual is incomplete and incorrect. This information was taken from the README file on the release disk.
CREATING APPLICATION ICONS WITH ResEdit
The following resources (located in a compiled QuickBasic application) can be modified with ResEdit to give an application and its documents their own customized icons: BNDL; FREF; ICN#; and the sample "signature" resource, "MBCB". The information in the Finder's Get Info dialog box for the application can also be specified.
You can create a compiled program with its own icon, and it can create document files with their own icons. A document file can be assigned its own icon by changing its file and creator types to correspond to resource information stored in the compiled application. The icon for a given document file type is taken from the resource fork of the compiled application and stored in the Finder's Desktop file.
The default creator code is blank, and the default file type is "TEXT", for files created with the OPEN statement. The creator and file types of a document must be changed by your QuickBasic program after the file is created.
- Change the creator type of a document using the SetCreate MBLC library routine, as follows:
- Change the file type using the NAME statement, as follows:
NAME docfile$ AS docfile$,"MYFT"
Double-clicking a document icon runs the associated application. By PEEKing through a handle to the application parameters, your application can determine which file was selected. See "File Browser.source" on the Examples disk for sample code that does this.
Here are step-by-step instructions for creating your own icons:
- Compile a program using Microsoft QuickBasic. For this example, assume the compiled program is called "MYPROGRAM apl".
- Run ResEdit.
- Double-click on the "MYPROGRAM apl" application.
- Select New from the File menu, then do the following:
- Type a unique creator resource type, for example: "MYAP".
- The following window appears: "MYAP's from MYPROGRAM apl".
- Select New from the File menu.
- Close the new resource window.
- Choose Get Info from the File menu and change the number that appears in the first "ID:" box to 0 (zero).
- Close the window.
- Perform the following steps if you wish to put a string in the file's Get Info box in the Finder:
- Select the new resource, and choose Open As from the File menu.
- Select type "STR " (NOT "STR#").
- Type the text that you want to appear in a Get Info from the Finder.
- Close windows. If you do not want text to appear in the Get Info window, then open the resource, and type three zeros.
- Double-click on BNDL, then do the following:
- Double-click on "BNDL=128".
- Change OwnerName to be the same as the unique, four-character, application resource type used in Step 4a ("MYAP").
- Close two windows.
- Perform this step if you want custom document icons:
- Double-click on FREF.
- Double-click on "FREF=129".
- Change the "File Type" to "MYFT". This is the type used in the NAME statement in the "MYPROGRAM apl" program.
- Close two windows. No other program will be able to open your documents. You do not need to change the file type if your application creates plain text files (type TEXT).
- Double-click on ICN#.
- Edit the application icon and, if desired, the document icon. Then select "Data to Mask" from the ICN# menu.
- Close three windows.
- Click YES to Save.
- While the "MYPROGRAM apl" application is highlighted, select Get Info from the File menu.
- Change the Creator to the unique four-character application creator resource name used in Step 4a ("MYAP").
- Close the window.
- Click YES to Save.
- Rebuild the Macintosh Desktop in either of the following ways:
- While holding down the COMMAND and OPTION keys, select Quit from the File menu, and keep holding down the COMMAND and OPTION keys until a dialog box appears. Click YES to rebuild the Desktop.
- Or, select the Desktop file in ResEdit, and choose Clear from the Edit menu. Quitting ResEdit now rebuilds the Desktop.
Additional Document Types
To add an icon for an additional file type that your application creates, add another icon to the ICN#, another FREF, and entries for the icon and FREF in the BNDL resource.
To add the FREF, open your application with ResEdit, and open the FREFs. Select New to create a new FREF, then set the file type to your new type, and set a new localID (3 for the first additional file type). Close the FREF and select Get Info to change the resource ID to the next in line (130 for the first additional file type).
To add an icon, open the ICN# in the application. Select New or Duplicate to create a new icon. Alter as you like, close it, Get Info, change the ID (again, 130 for the first additional).
Now open the application's BNDL. Find the line of dashes under the ICN#. Click on the line and select New. Fill in the localID and Resource ID to correspond with the icon and FREF you created. Do the same with the line of dashes under FREF.
As before, you must rebuild the Desktop to see the new icons.
Additional query words: MQuickB readme docerr