[comp.sys.mac.programmer] Changing icons using resedit

ckl@goanna.oz (Chee Kheong Lin) (10/10/88)

I suppose the subject heading says it all; I've built an application
using LightSpeed Pascal and I want to change the application icon into
something other than the default icon (ie. the one with the hand
resting on a square). I did the following which is from S.
Chernikoff's "Macintosh Revealed Vol. II" :

1) Create autograph resource (I called it CLIN, ID 0) containing string
identifying program version and date.
2) Create a file reference (resource type FREF, ID 128) with
associating type APPL and icon number 0.
3) Create an icon (resource type ICN#, ID 128) that I want my application 
to be represented as. 
3) Create a bundle (resource type BNDL, ID 0) giving owner name and ID
of autograph resource (in this case, CLIN and ID 0) and associating
icon list 0 with actual ID 128.

Problem: icon remains unchanged. Any advice, suggestions would be
greatly appreciated.

BTW, Chernikoff referenced Vol. III several times in his book. I was
wondering if anyone knows whether Vol. III is out already or is there
really a Vol. III?? Also can anybody recommend any other good Toolbox
programming books besides Inside Macintosh. I prefer something with 
plenty of examples in it. 
-------
Chee Kheong Lin

+----------------------------------------------------------------------+
|Dept. of Computer Science  ACSnet: ckl@goanna.oz		       |
|124 La Trobe Street        CSNET:  ckl@goanna.rmit.oz		       |
|Melbourne		    ARPA:   ckl%goanna.rmit.oz@seismo	       |
|Victoria 		    UUCP: ...!seismo!munnari!goanna.rmit.oz!ckl|
|Australia 3000.	    					       | 
+----------------------------------------------------------------------+

bob@eecs.nwu.edu (Bob Hablutzel) (10/13/88)

> Problem: icon remains unchanged. Any advice, suggestions would be
> greatly appreciated.

It looks like you may have forgotten one of two steps:

1) Setting the creator for the application to your signature,
2) Setting the bundle bit for the application. 

Either of these can be done with ResEdit.

Bob Hablutzel		BOB@NUACC.ACNS.NWU.EDU

steele@unc.cs.unc.edu (Oliver Steele) (10/14/88)

ckl@goanna.oz (Chee Kheong Lin) writes that he's trying to give an
application an icon:

>1) Create autograph resource (I called it CLIN, ID 0) containing string
>identifying program version and date.
>2) Create a file reference (resource type FREF, ID 128) with
>associating type APPL and icon number 0.
>3) Create an icon (resource type ICN#, ID 128) that I want my application 
>to be represented as. 
>3) Create a bundle (resource type BNDL, ID 0) giving owner name and ID
>of autograph resource (in this case, CLIN and ID 0) and associating
>icon list 0 with actual ID 128.

4) Set the Bundle bit of the file ("Get Info" on the file from ResEdit,
for instance), and unset the Inited bit, if the latter is set.  LSC, at
least, does this automatically if the .rsrc file from which it built the
APPL had the appropriate resources.
5) If you were changing the icon for a file that already had one, or
adding new file type icons, you'd need to either perform appropriate
surgery on or rebuild the Desktop.  It's a lot easier just to rebuild it.

You also need to put FREF 0/128 in the BNDL, as well as ICN# 0/128.
Couldn't tell if you'd done that.
 ---------------------------------------------------------------------------
 Oliver Steele					  ...!decnet!mcnc!unc!steele
 UNC-CH							   steele@cs.unc.edu

 "It's not the easy way --
  but it's the cowboy way!"		- Riders in the Sky

ech@poseidon.ATT.COM (Edward C Horvath) (10/15/88)

From article <1675@goanna.oz>, by ckl@goanna.oz (Chee Kheong Lin):
> 3) Create a bundle (resource type BNDL, ID 0) giving owner name and ID
> of autograph resource (in this case, CLIN and ID 0) and associating
> icon list 0 with actual ID 128.

You also need to include an FREF in the BNDL.  Finally, you may need to
rebuild the DeskTop (hold down cmd-option when inserting the disk; hold 'em
down at reboot time to rebuild the startup disk's Desktop).

=Ned Horvath=

alexis@ccnysci.UUCP (Alexis Rosen) (10/15/88)

In article <10050029@eecs.nwu.edu> bob@eecs.nwu.edu (Bob Hablutzel) writes:
>> Problem: icon remains unchanged. Any advice, suggestions would be
>> greatly appreciated.
>
>It looks like you may have forgotten one of two steps:
>1) Setting the creator for the application to your signature,
>2) Setting the bundle bit for the application. 
>Either of these can be done with ResEdit.

There is one more step. If the Finder has seen your Application, it will mark
it as "Inited".  The Finder only gets bundles (and does all that other good
stuff necessary to give your app an Icon) when it sees a file for the first
time. To tell it that your app now has a budle which it didn't before, you
can use ResEdit (or DiskTools, or many other tools) to set its "Inited"
attribute off. The next time you open the app's folder (or re-enter the Finder,
under UniFinder), it will get the bundle, put it in the desktop file, and
you'll have your icon.

Two other (much less nice) ways of doing this are rebuilding the desktop and
copying the file to another disk.

----
Alexis Rosen                       {allegra,philabs,cmcl2}!phri\
Writing from                                {harpo,cmcl2}!cucard!dasys1!alexis
The Big Electric Cat                  {portal,well,sun}!hoptoad/
Public UNIX                         Best path: uunet!dasys1!alexis
                                     or try: alexis@ccnysci.UUCP

jrk@s1.sys.uea.ac.uk (Richard Kennaway CMP RA) (10/17/88)

[A followup to a question and various answers to problems in changing
BNDL/ICN#/FREFs properly]

Another pitfall to beware, which I havent seen described anywhere, is that
under MultiFinder, if the file whose icon you are trying to change is visible
in a finder window or on the desktop, changing the type and/or creator
of the file can have no effect - the Finder (or something) sets it back
to what it was.  Always close the Finder window containing the file, or
move it into a closed folder, before hacking the types.

Anyone know why this should happen?  The workaround works, but dammit, Mac
software shouldnt have to be worked around :-)
-- 
Richard Kennaway
School of Information Systems, University of East Anglia, Norwich, U.K.
uucp:	...mcvax!ukc!uea-sys!jrk	Janet:	kennaway@uk.ac.uea.sys

peterson@peterson.applicon.UUCP (10/19/88)

I ran into the problem of an icon refusing to change (I hope I am addressing
the correct problem here!).  My problem was answered on this net, and I will
repeat the solution.
   The Desktop file (that invisible file on every disk) does not change
automatically when you change the ICN# resource in a application.  The
Desktop must be rebuilt.  An easy way to do this is to hold down the
option & command keys while rebooting.


Joe Peterson

uucp: peterson@applicon.com

kucharsk@amdahl.uts.amdahl.com (William Kucharski) (10/19/88)

In article <160@s1.sys.uea.ac.uk> jrk@s1.sys.uea.ac.uk (Richard Kennaway CMP RA) writes:
 >[A followup to a question and various answers to problems in changing
 >BNDL/ICN#/FREFs properly]
 >
 >Another pitfall to beware, which I havent seen described anywhere, is that
 >under MultiFinder, if the file whose icon you are trying to change is visible
 >in a finder window or on the desktop, changing the type and/or creator
 >of the file can have no effect - the Finder (or something) sets it back
 >to what it was.  Always close the Finder window containing the file, or
 >move it into a closed folder, before hacking the types.
 >
 >Richard Kennaway
 >School of Information Systems, University of East Anglia, Norwich, U.K.
 >uucp:	...mcvax!ukc!uea-sys!jrk	Janet:	kennaway@uk.ac.uea.sys

Actually, if I'm not mistaken, it's generally BAD to be using ResEdit under
MultiFinder anyway.  Although I've never had any problems doing it, I've
been warned against it enough by various people and publications to not do it
anymore.  Does anyone else know if I'm being safe/over cautious?




-- 
					William Kucharski

ARPA: kucharsk@uts.amdahl.com
UUCP: ...!{ames,decwrl,sun,uunet}!amdahl!kucharsk

Disclaimer:  The opinions expressed above are my own, and may not agree with
	     those of any other sentient being, not to mention those of my 
	     employer.

ckl@goanna.oz (Chee Kheong Lin) (11/03/88)

From article <77900006@peterson>, by peterson@peterson.applicon.UUCP:
> 
> I ran into the problem of an icon refusing to change (I hope I am addressing
> the correct problem here!).  My problem was answered on this net, and I will
> repeat the solution.
>    The Desktop file (that invisible file on every disk) does not change
> automatically when you change the ICN# resource in a application.  The
> Desktop must be rebuilt.  An easy way to do this is to hold down the
> option & command keys while rebooting.
> 
> 
> Joe Peterson
> 
> uucp: peterson@applicon.com

I posted the original query about changing icons a while back. And I
got back two solutions. The first one is the one you mentioned above.
The second one is where you go into Resedit, do a 'Get Info' on the
application and set the bundle bit. That seems to work fine for me.
I haven't tried the first solution mentioned above. To all the people
who took the time and trouble to reply my query, thank you very much!!

Chee Kheong Lin

+----------------------------------------------------------------------+
|Dept. of Computer Science  ACSnet: ckl@goanna.oz		       |
|124 La Trobe Street        CSNET:  ckl@goanna.rmit.oz		       |
|Melbourne		    ARPA:   ckl%goanna.rmit.oz@seismo	       |
|Victoria 		    UUCP: ...!seismo!munnari!goanna.rmit.oz!ckl|
|Australia 3000.	    					       | 
+----------------------------------------------------------------------+

ckl@goanna.oz (Chee Kheong Lin) (11/17/88)

OK, here we go again. A few weeks ago I asked for some info on how to
built my own icon for my application program. Thank you to all those
who took the time and trouble to reply. That part works fine now.

Now I want to associate an icon with a text documnent which the
application program creates. And I also want to be able to open that
text document by just double-clicking on it. I've gone thru the usual
procedure of creating icon, creating a FREF record for it, setting the
type to 'TEXT', adding the id to the resource BNDL. But when I create
a new document from my application program, it still uses the normal
document icon. I did a 'Get Info' on that document in ResEdit and
found that the creator field is empty. But when I changed that field 
into the name of my autograph, it works fine. I suspect the problem is
that it can't find the name of my autograph. How do I get it to find
the name?? Have I missed something?? Thanx in advance.

Chee Kheong Lin

+------------------------------------------------------------------------+
|Dept. of Computer Science  ACSnet: ckl@goanna.cs.rmit.oz.au 	         |
|124 La Trobe Street        CSNET:  ckl%goanna.cs.rmit.oz.au@australia   |
|Melbourne		    ARPA:   ckl%goanna.cs.rmit.oz.au@uunet.uu.net|
|Victoria 		    UUCP: ...!uunet!goanna.cs.rmit.oz.au!ckl     |
|Australia 3000.	    					         | 
+------------------------------------------------------------------------+

bob@eecs.nwu.edu (Bob Hablutzel) (11/18/88)

.Now I want to associate an icon with a text documnent which the
.application program creates. And I also want to be able to open that
.text document by just double-clicking on it. I've gone thru the usual
.procedure of creating icon, creating a FREF record for it, setting the
.type to 'TEXT', adding the id to the resource BNDL. But when I create
.a new document from my application program, it still uses the normal
.document icon. I did a 'Get Info' on that document in ResEdit and
.found that the creator field is empty. But when I changed that field 
.into the name of my autograph, it works fine. I suspect the problem is
.that it can't find the name of my autograph. How do I get it to find
.the name?? Have I missed something?? Thanx in advance.

Are you changing the creator and type for the file with GetFileInfo and
SetFileInfo? The creator and type of a file are not properly set when a 
file is created - you have to set them by hand.

Bob Hablutzel	BOB@NUACC.ACNS.NWU.EDU