Being Resourceful with Delphi 7

With TImageLists and other  components that allow you to embed rich media in your applications, developers don’t often need to use resource-definition script (.rc) files and compile them into resource (.res) files.  I recently came across the need to do so for 24 bit PNG images, so I thought I would author an article in case I need to remember this in the future.  Hopefully someone else will also find it useful.  There are good resources out there, such as the articles on delphi.about.com, but I found conflicting information on how best to include them.

For instance, on StackOverFlow the question came up in June 2009 with a reply to include the following in your project:

{$R 'Splash.res' 'Splash.rc'}
Above directive is what I use to include an image for a splash screen. It will automatically compile the .RC file. As an option, you can just include the .RC to your Delphi project, in which case the above line will be added to your project file (*.DPR) and it will also automatically compile. (And you can use Delphi to edit the .RC file.)

What I found out by experimentation is that Delphi 7 doesn’t actually compile the RC file into a RES file as indicated above, even when you build the project.  It will include the RES file, but you still have to manually compile the RC file into a RES file using BRCC32 just as delphi.about.com indicates.  You can associate BRCC32 with an RC file so double clicking it will compile it, but Delphi 7 will not automatically invoke BRCC32 as part of the compile process, so if your RC file changes you have to remember to update the RES file.

You can in fact add the RC files to your Delphi project in the Project Manager.  The advantage to adding them to the project is that you can edit the file as a Text File in the Delphi IDE, or invoke the String Table editor by Rt. Clicking on the file in the Project Manager.  It does not change the fact that RES files are not generated by a Build.

Sometimes I really wish Borland would have logged the output from the compiler and the rest of the toolchain so you could tell what was going on in these earlier Delphi versions.  Of course a real resource editor would have been a nice feature as well!

One Response to “Being Resourceful with Delphi 7”

  1. Paul Says:

    Resource files are very useful, I’ve had a few issues, including PNG file problems… http://stackoverflow.com/questions/2470086/d2007-december-2007-update-brcc32-ico-res-and-colour-depth-issue-clarificat

Leave a Reply