Articles 3D Audio Custom Controls General RB Graphics Hacks Mac OS X Menus Novelty Printing REALbasic 2005 REALbasic 2006 Registration Resources Reviews Serial Speech Sockets XML Video Resource Links News Current News February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 May 2005 April 2005 March 2005 ![]() REALbasic for Dummies by Erick Tejkowski ![]() Learning REALbasic through Applications REALbasic for Macintosh REALbasic Cross-Platform Application Development
Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander |
|
A popular new addition to the ResExcellence site is the iTunes Skins section. To install any of these skins within iTunes, you must:
Although this is pretty much a no-brainer, we can make it even easier using REALbasic. This week we'll whip up a quick hack that makes this process a little more streamlined. It's not the flashiest project, but maybe it will give you some ideas for other useful hacks you can create with REALbasic. Building the Interface Launch REALbasic and open the default window, entitled Window1. Add a Listbox to the window. We will display the resources types from the skin file here. Feel free to spruce up the interface any other way you see fit. A sample interface might look like this:
Define the File Types Since we want to work with two kinds of files (the skin file and the iTunes application itself), we need to describe them to REALbasic. Select Edit->File Types... and define two types of files:
For the ResEditFile file type, enter the following infortmation:
For the iTunes file type, enter this data:
Add the Code Now that we have built the interface and defined the file types our project will use, it's time to add the code. The main idea behind this project is to copy all of the resources from the resource fork of a ResEdit skin file to the resource fork of iTunes. Right now would be a good time to make a backup copy of iTunes, since you will be modifying the iTunes application. To simplify matters, we will permit a user to drag a skin file into thw interface window. To make the window drag and drop aware, add this code to the Open event of Window1: me.acceptfileDrop("ResEditFile")Finally, add this code to the DropObject event of Window1: dim i, j, rcount, thisresourcenumber as integerdim fSkin, fiTunes as folderItem dim rfiTunes, rfSkin as resourceFork dim rtype, junk, s, thisresourcetype as string //is "obj" a FolderItem? if obj.folderItemavailable then //the folderitem of the skin file fSkin = obj.FolderItem junk = chr(0)+chr(0)+chr(0)+chr(0) fiTunes = GetOpenFolderItem("iTunes") //first loop through all resource types in the if fiTunes<>nil and fiTunes.exists then if fSkin.exists then //open the skin's resource fork rfSkin = fSkin.openresourcefork //open the iTunes resourcefork rfiTunes = fiTunes.openresourcefork //clear listbox listBox1.deleteAllRows //we don't know how many types //of resources there are //we will assume that there are no more //than 10,000 resource types for i=1 to 10000 rtype = rfSkin.ResourceType(i-1) if rfSkin.ResourceType(i-1)<>junk then //we found a resource type, //so add it to the list listBox1.addrow rfSkin.ResourceType(i-1) end if next end if if listBox1.listcount>0 then //loop through all resource types for i=1 to listBox1.listcount thisresourcetype = listBox1.list(i-1) rcount = rfSkin.resourcecount(thisresourcetype) //loop through all resources of this type for j=1 to rcount //find resource number for this resource thisresourcenumber = rfSkin.resourceid(thisresourcetype,j-1) //retrieve the resource //from the skin source file s = rfSkin.getresource(thisresourcetype, thisresourcenumber) //copy the resource to iTunes rfiTunes.AddResource(s, thisresourcetype, thisresourcenumber, "") next//j next//i end if //close the resource fork of the skin and iTunes rfiTunes.close rfSkin.close end if//fiTunes<>nil and fiTunes.exists end if//obj.folderItemavailable then Conclusion As usual, you can download the project and completed application. If you are an astute ResExer, you may realize that this project could be easily modified to work with a number of ResExcellence hacks and improvements. This project lends itself well to any instance where you need to copy resources from one file to another. Happy experimenting! |
||||
|
||||||||||||||||||||||||||||||||
Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement.
[an error occurred while processing this directive]