Re: NSData to IconFamilyHandle woes
Re: NSData to IconFamilyHandle woes
- Subject: Re: NSData to IconFamilyHandle woes
- From: Bill Monk <email@hidden>
- Date: Fri, 19 Aug 2005 13:49:38 -0500
On Aug 18, 2005, at 10:40 PM, Colin Cornaby wrote:
when I attempt to copy the initial
handle into an IconFamily handle it returns an error negative -50, or
a parameter error. Searching the list shows everyone else who has
tried this getting stuck at the exact same point.
Probably because SetIconFamilyData() expects the IconFamilyHandle to
contain a valid IconFamilyResource struct. Your code passes it a
handle to nothing. Hence: paramErr.
Instead of this:
IconFamilyHandle iconFamily= (IconFamilyHandle) NewHandle(0);
theErr=SetIconFamilyData (iconFamily, 'icns', theHandle);
Try this:
// Size of an empty IconFamilyHandle is sizeof
( IconFamilyResource.resourceType ) +
// sizeof ( IconFamilyResource.resourceSize ) == 8;
//
// See <IconStorage.h> and http://developer.apple.com/samplecode/
SetCustomIcon/listing1.html
IconFamilyHandle iconFamily = (IconFamilyHandle)NewHandle( 8 );
// fill in the basics. SetIconFamilyData() will update resourceSize
when it adds data to the handle.
(**icnsH).resourceType = kIconFamilyType;
(**icnsH).resourceSize = 8;
theErr = SetIconFamilyData (iconFamily, 'icns', theHandle);
Also...that second parameter. Shouldn't it be the type of icon data
being added, such as kLarge32BitData, kHuge32BitData, etc. Will
kIconFamilyType 'icns' work there?
If the NSData actually contains an entire icon family (complete with
the initial resourceType and resourceSize fields correctly filled in)
then you don't need SetIconFamilyData(). Just put the data into a
Handle, as you're already doing, and you're done:
IconFamilyHandle theHandle = (IconFamilyHandle)NewHandle
([[resourceToSet resourceData] length]);
BlockMove([[resourceToSet resourceData] bytes], *theHandle,
[[resourceToSet resourceData] length]);
(FWIW, it used to be that BlockMove() flushed processor caches on
moves larger than 12 bytes. Presumably that's still true, and
BlockMoveData() should be used, except at interrupt time.)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden