[futurebasic] Re: [FB] Use Custom Icon

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 1999 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Wed, 27 Jan 1999 18:42:52 -0600

Sylvain Guillemette wrote:

> I want to set the Finder Flag 'Use Custom Icon' for
> a file or an application. (within FB)
>
> How can i set this flag ?
>

I have not tested this idea, but I think you should be able to do it by
following these basic steps:

1. Call HGETFILEINFO to return a parameter block
   containing all the file's current info (including the
   "Use Custom Icon" bit).
2. Set the bit in the parameter block.
3. Call HSETFILEINFO to change the file's info.

For example (untested function!)

LOCAL FN SetCustomIconBit(filename$, wdRefNum)
  DIM pb.128
  pb.ioNamePtr& = @filename$
  pb.ioVRefNum% = wdRefNum
  pb.ioDirID& = 0
  pb.ioFDirIndex% = 0
  OSErr = FN HGETFILEINFO(@pb)
  'Set the "Custom Icon" bit:
  pb.ioFlUsrWds.fdFlags% = pb.ioFlUsrWds.fdFlags% OR BIT(10)
  'Set ioDirID& again, because HGETFILEINFO alters it:
  pb.ioDirID& = 0
  OSEff = FN HSETFILEINFO(@pb)
END FN

Of course, it's also important that you remember to actually put the custom
icon resource into the file's resource fork--but I suppose you already knew
that.

Hope this helps.

- Rick