Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/34351

From BetaArchive Wiki

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.




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.

  1. Change the creator type of a document using the SetCreate MBLC library routine, as follows:

    SetCreate docfile$,"MYAP"

  2. 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:

  1. Compile a program using Microsoft QuickBasic. For this example, assume the compiled program is called "MYPROGRAM apl".
  2. Run ResEdit.
  3. Double-click on the "MYPROGRAM apl" application.
  4. Select New from the File menu, then do the following:

    1. Type a unique creator resource type, for example: "MYAP".
    2. The following window appears: "MYAP's from MYPROGRAM apl".
    3. Select New from the File menu.
    4. Close the new resource window.
    5. Choose Get Info from the File menu and change the number that appears in the first "ID:" box to 0 (zero).
    6. Close the window.
    7. Perform the following steps if you wish to put a string in the file's Get Info box in the Finder:

      1. Select the new resource, and choose Open As from the File menu.
      2. Select type "STR " (NOT "STR#").
      3. Type the text that you want to appear in a Get Info from the Finder.
      4. Close windows. If you do not want text to appear in the Get Info window, then open the resource, and type three zeros.
  5. Double-click on BNDL, then do the following:

    1. Double-click on "BNDL=128".
    2. Change OwnerName to be the same as the unique, four-character, application resource type used in Step 4a ("MYAP").
    3. Close two windows.
  6. Perform this step if you want custom document icons:

    1. Double-click on FREF.
    2. Double-click on "FREF=129".
    3. Change the "File Type" to "MYFT". This is the type used in the NAME statement in the "MYPROGRAM apl" program.
    4. 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).
  7. Double-click on ICN#.

    1. Edit the application icon and, if desired, the document icon. Then select "Data to Mask" from the ICN# menu.
    2. Close three windows.
    3. Click YES to Save.
  8. While the "MYPROGRAM apl" application is highlighted, select Get Info from the File menu.

    1. Change the Creator to the unique four-character application creator resource name used in Step 4a ("MYAP").
    2. Close the window.
    3. Click YES to Save.
  9. Rebuild the Macintosh Desktop in either of the following ways:

    1. 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.
    2. 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

Keywords: KB34351