PDA

View Full Version : programmatically set background image of folder




ZacharyDenison
Apr 7, 2008, 01:03 PM
Hello,

I am trying to make a small drag-n-drop utility with Xcode in Objective-C / Cocoa to create dmg files, I am not sure how to programmatically set the background image of a folder. Does anyone know the name of the class that handles this?

Thank you.

Zach.



robbieduncan
Apr 7, 2008, 01:58 PM
There is not a Cocoa interface to this. Probably the easiest way is to tell the Finder to do it via Applescript.

yeroen
Apr 7, 2008, 02:05 PM
You'll have to manipulate the Folder image, which typically (I believe) is stored in a resource fork. I not 100% about Cocoa, but other frameworks (like Qt) allow you to manipulate images by applying transparency masks. You could layer the new image onto the folder image, flatten, then write back to the file.

There's probably a simpler way of doing this, but I don't know what that might be.

Bakerman
Dec 8, 2008, 03:02 AM
I came here looking for the answer to the same question, and eventually found the answer from the mothership itself:

http://docs.info.apple.com/article.html?path=AppleScript/2.1/en/as2039.html

(there's a handy example at the bottom of that page)