Managing Resources in the IDE

In the most recent versions of Delphi, you could add resource scripts (.RC files) or compiled resource files (.RES files) to the Project Manager to let it compile them along with the project linking them to the executable. In Delphi 2009 managing resources has been simplified by the inclusion of a few more tools.

First, you can now drag individual resource files to the Project Manager to get them included as resources in a project. You can drag icons, bitmaps, and more. Delphi will generate a resource script files for these extra project resources, and compile it directly along with your program, embedding these resources in the executable. You can change any attribute of these resource files (including their internal name) in the Object Inspector:

Object Inspector

J Properties [

File Name » Full Path

SHIPPING.BMP

SHIPPING.BMP

Resource Identifier Bitmap_Shipping Resource Type Bitmap

Second, under the Project pull-down of the main menu of the IDE there is a new menu item, Resources. Selecting this items brings up the Resources dialog box, which you can use to revise all of the resources of the program, add new resource files, rename them, change the format, and so on:

By adding a few resources to a project, at compile time Delphi will generate a proper resource file for you. For the ResourceTest program (with the resources depicted above), Delphi 2009 generates a resource script file listing the project resources called ResourceTestResource.rc:

Icon_Factory Icon "FACTORY.ICO" Bitmap_Shipping Bitmap "SHIPPING.BMP"

This resource script file is not added to the project (if you do so, you'll see duplicate resource warnings), but it is compiled along with it. In fact, if you make an error, like declaring your bitmap as an icon, the compiler will stop with the error:

  • BRCC32 Error] ResourceTestResource.rc(2): resource file SHIPPING.BMP is not in 3.00 format and open the resource script file at the offending line. At compile time, Delphi 2009 generates (or updates) the resource script file, compiles it, and binds it to the executable. The intermediary file is a file with extension DRES that's included in the project with a directive automatically added to the project source code file (along side with the standard RES file including the project icon and string resources): program ResourceTest;
  • R *'.dres}
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment