Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / June 2005



Tip: Looking for answers? Try searching our database.

how to load a resource os x 10.x

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
omacdog - 24 Jun 2005 16:17 GMT
Hi I'm not able to load a Image.rsrc file at runtime and can't find
out how its done. The icns images and picts are usable in interface
builder. The executable resource fork contains the Image.rsrc, but
it just can't find it at runtime.

Oh and wasn't it fun trying to import a resource in IB using 'import
resource', when in fact, the resources have to be imported from the
XCode project IDE when IB launches - another great apple idea!  :E

suggestions welcome

* posted via http://www.mymac.ws
* please report abuse to http://xinbox.com/mymac
Michael Dautermann - 25 Jun 2005 09:57 GMT
>Hi I'm not able to load a Image.rsrc file at runtime and can't find
>out how its done. The icns images and picts are usable in interface
>builder. The executable resource fork contains the Image.rsrc, but
>it just can't find it at runtime.

Resource files are still loadable in Carbon applications (that is,
I'm assuming you're using Carbon).

First thing you have to do is tell your application where the
resource file might be found.  

CFBundleGetMainBundle() - gets the main application bundle
CFBundleCopyResourceDirectoryURL() -- returns the location of a bundle's
  resource directory
CFURLGetFSRef() - to convert the resource directory URL into something
  you can really use
FSGetCatalogInfo() - converts the FSRef into an FSSpec
FSpOpenResFile() - to open the res file
UseResFile() - finally, you can access your resources

I wonder if anybody has a more simple way to do this.  :-)

Hope this information helps!

Signature

- myke  @  umich.edu                        = Grad. Student Emeritus -
- mike  @  mac.archive.umich.edu            = MISTER archive         -
- http://www-personal  .umich  .edu/~myke   = my web page            -
- Michael Dautermann...   U-M Alumni calling in from way out there   -

Chris Baum - 26 Jun 2005 05:33 GMT
> I wonder if anybody has a more simple way to do this.

It's 2005.  Stop using .rsrc and switch to .icns and .png files?
omacdog - 28 Jun 2005 09:19 GMT
> CFBundleGetMainBundle() - gets the main application bundle

> CFBundleCopyResourceDirectoryURL() -- returns the location of a
> bundle's

> resource directory

> CFURLGetFSRef() - to convert the resource directory URL into something

> you can really use

> FSGetCatalogInfo() - converts the FSRef into an FSSpec

> FSpOpenResFile() - to open the res file

> UseResFile() - finally, you can access your resources

It's 2005.  Stop using .rsrc and switch to .icns and .png files?

Thanks for the suggestions! I was expecting the executable to do a
default search in the apps resource fork to find resources. I should
have guessed that it wouldn't.

* posted via http://www.mymac.ws
* please report abuse to http://xinbox.com/mymac
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.