mg5184@mars.njit.edu (Michael Gaines) (12/31/90)
OK,
Here's the deal. I've been racking my brains with this and the
limited number of resources I've had available to me. I'm writing a
program (no kidding) in which data files are created. I want to know how
to copy an icon from my ICN# list to be the desktop icon for my data
file. ALSO, I would have to change the owner of the data file. Please,
don't kick me if this is something too obvious. I thought there was a
resource fork at work here, but my data files from MathCAD and Word have
unique icons and no resource forks.
Mike
====================================================================
| Dunn was over Unger and I was over Dunn! | mg5184@mars.njit.edu |
====================================================================
hairston@henry.ece.cmu.edu (David Hairston) (01/01/91)
[mg5184@mars.njit.edu (Michael Gaines) writes:] [] Here's the deal. I've been racking my brains with this and the [] limited number of resources I've had available to me. I'm writing a [] program (no kidding) in which data files are created. I want to know how [] to copy an icon from my ICN# list to be the desktop icon for my data [] file. ALSO, I would have to change the owner of the data file. Please, [] don't kick me if this is something too obvious. I thought there was a [] resource fork at work here, but my data files from MathCAD and Word have [] unique icons and no resource forks. Welcome to Macintosh ... The Finder handles the icon'ing. The gist of the matter is that the Finder oversees a database of file types and associated icons related to a given file creator. Typically, the Finder will look for a file of type APPL and make a note of its creator signature (let's say FOO1). The Finder will then read the applications file reference bundle, a group of resources: BNDL, FREF and ICN# where the BNDL pairs a FREF to a particular ICN#. In this way an application can specify, for example, that all files with type FOO2 and creator FOO1 will have the icon denoted by the BNDL pairing. Thus the document file (FOO2 with creator FOO1) need not have a resource fork, just the right finder info. Here's a concrete example (from memory) for MacDraw: Finder Info: MacDraw macdraw.1 macdraw.2 type APPL DRWG PICT creator MDRW MDRW MDRW Resources: bundle BNDL <none> <none> ref FREF <none> <none> icon ICN# <none> <none> the BNDL assigns MDRW as the creator signature for file types APPL, DRWG and PICT and associates an icon with each type. The Finder copies this info into a private database and does the necessary magic to enable you to see a particular icon for a given file type (and creator). Using finder info calls you can change a files signature (creator and type) so that it will display associated existing icons. You can create icons and bundles, etc. with a resource editor and manipulate them with toolbox calls. For more info you are referred to Inside Macintosh, Vol. III (i think), the section dealing with Finder Info (should be near the beginning). -dave- hairston@henry.ece.cmu.edu
stevec@Apple.COM (Steve Christensen) (01/03/91)
mg5184@mars.njit.edu (Michael Gaines) writes: > Here's the deal. I've been racking my brains with this and the >limited number of resources I've had available to me. I'm writing a >program (no kidding) in which data files are created. I want to know how >to copy an icon from my ICN# list to be the desktop icon for my data >file. ALSO, I would have to change the owner of the data file. Please, >don't kick me if this is something too obvious. I thought there was a >resource fork at work here, but my data files from MathCAD and Word have >unique icons and no resource forks. You don't have to do any copying of icons since the Finder is the one that manages all the icons. You just have to supply them (and a couple of other resources) as part of your application. Suppose you have an application and document with the following types/creators: application document type APPL ADOC creator MYAP MYAP Your application needs to contain 5 resources to manage all this: a bundle resource (BNDL), 2 icons (ICN#) and 2 file reference resources (FREF). Putting it all together looks like this in MPW's Rez: resource 'BNDL' (128) { 'MYAP', /* application's creator */ 0, /* owner ID */ { 'ICN#', /* list of associated icons */ { 0, 128; /* application's local ID, resource ID */ 1, 129; /* document's local ID, resource ID */ }; 'FREF', /* list of associated file references */ { 0, 128; /* application's local ID, resource ID */ 1, 129; /* document's local ID, resource ID */ }; } }; resource 'ICN#' (128) { /* application's icon */ { $"xxxxxxx"; /* icon data */ $"xxxxxxx" /* icon mask */ } }; resource 'ICN#' (129) { /* document's icon */ { $"xxxxxxx"; /* icon data */ $"xxxxxxx" /* icon mask */ } }; resource 'FREF' (128) { /* application's file reference */ 'APPL' /* application's file type */ 0, /* application icon's local ID */ "" /* associated file (none) */ }; resource 'FREF' (129) { /* document's file reference */ 'ADOC', /* document's file type */ 1, /* document icon's local ID */ "" /* associated file (none) */ }; If you're using ResEdit to create the resources, you can just create new resources of the appropriate types and IDs and fill in the blanks with the values above, and then edit the icons graphically. Once you've got all the resources built, you need to do one more thing to let the Finder know that there are icons to be found in the application file. You need to set the bundle bit in the application's file attributes. From MPW, you can do this with SetFile "app's name" -a B , and from ResEdit you can click on the bundle checkbox in the file's Get Info window. You may find that the application's icon still doesn't show up in the Finder. The fast way to fix this is to make sure that whatever window the application's icon shows up in is closed, then jump into ResEdit, do a Get Info on the file, and make sure the bundle checkbox is checked and the inited checkbox isn't. Then quit back to the Finder, open the window with the application, and its icon should show up. Creating data files with the appropriate icon then becomes the simple matter of doing: PBHDelete() /* to get rid of an existing file */ PBHCreate() /* to create a new file */ PBHGetFInfo() /* to get the current file info */ set the type to (for example) 'ADOC' and creator to 'MYAP' in the parameter block PBHSetFInfo() /* to update the type and creator */ PBHOpen() write, write write PBHClose() and that's it... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen | Apple Computer, Inc. | Disclaimer: | 20525 Mariani Ave, MS-81CS | the above may be stevec@apple.com | Cupertino, CA 95014 | a lie...or not.
Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) (01/03/91)
MG> Here's the deal. I've been racking my brains with this and the MG> limited number of resources I've had available to me. I'm writing MG> a program (no kidding) in which data files are created. I want MG> to know how to copy an icon from my ICN# list to be the desktop MG> icon for my data file. ALSO, I would have to change the owner MG> of the data file. Please, don't kick me if this is something MG> too obvious. I thought there was a resource fork at work here, MG> but my data files from MathCAD and Word have unique icons and MG> no resource forks. Mike The unique icons are stored in the resource fork of the application that creates the data files. The last time I explained this it took me four pages and a lot of screen dumps to make it clear. My best advice is to look around on line for the ResEdit Docs which explain it pretty well. There were also some pretty good descriptions of the precess available for DLing on the major BBS. In any case, take a good look at one of your Apps that creates a unique document icon with ResEdit. Pay attention to the ICN#, FREF and BNDL resources. Also note that the creator of the App and all it's documents must be the same. Note that the App must have its bundle bit set. Maybe you can figure it out from examples. -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org