FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Use custom icon


I use:

CLEAR LOCAL
LOCAL FN MakeFileCustomIcon%(filename$, vRefNum%)
DIM pbBlk.80
DIM osErr%
'_kHasCustomIcon = 1024

pbBlk.ioNamePtr& = @filename$
pbBlk.ioVRefNum% = vRefNum%
osErr% = FN GETFILEINFO (@pbBlk)
pbBlk.ioFinderInfo.fdFlags% = pbBlk.ioFinderInfo.fdFlags% OR
_kHasCustomIcon
osErr% = FN SETFILEINFO (@pbBlk)
END FN = osErr%

also use '_kCustomIconResource = -16455 when building the icons....

Michael Evans


Use this:

_useCustomIcon = &x0000010000000000

CLEAR LOCAL
LOCAL FN setFileBit (fileName$,volNum%, theBit&)
DIM pbBlk.80
DIM osErr%

pbBlk.ioNamePtr& = @fileName$
pbBlk.ioVRefNum% = volNum%
osErr% = FN GETFILEINFO (@pbBlk)
pbBlk.ioFinderInfo.fdFlags% = (pbBlk.ioFinderInfo.fdFlags% OR theBit&)
osErr% = FN SETFILEINFO (@pbBlk)
END FN = osErr%

fileName$ = FILES$(_fOpen,,,volNum%)

LONG IF LEN(fileName$)
FN setFileBit (fileName$,volNum%, _useCustomIcon)
END IF

John


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.

Rick