UBBFriend: Email This Page to Someone!
  Computer Workshop User Forums
  EZGUI Dialog Designers Tutorials
  Creating Resource Files

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Creating Resource Files
Chris Boss
Administrator
posted 02-20-2008 12:07 PM     Click Here to See the Profile for Chris Boss     Edit/Delete Message Reply w/Quote
The Dialog Designer can write a resource file for your app for you.

What is a resource file ?

Rather than load graphic images from a disk file during execution, a PB application can instead load its images from the EXE itself. This is done by adding a resource file and the compiler embeds those resources in your EXE. This makes it easier to distribute the application, since only the EXE is needed and no external image files.

A Resource file starts out as an RC (file extension .RC) file. The Designer has the ability to create an RC file for your app. It will be written to a subfolder RCDATA off the folder where your source code is.

The resource file will contain any images you define as well as all the "Resource File Definitions" (producte name, app name, copyright) you define in a projects property dialog.

How does the designer know what images to use as resources ?

In the project palette window there is a section:

RESOURCES

By clicking the "Add Graphic File" button an Open File dialog will appear so you can select an image file for a resource. Once selected another dialog will appear where you can select one of the options:

- Load from disk file
- Load from EXE ($)

By selecting the Load from EXE option, the Designer will flag the image to be added to the resource file. The generated code for loading the image will reflect this change as well.

How do you compile a resource file ?

Resource files (.RC) must be compiled first before they can be used in an application. The RC.exe program (in BIN folder of compiler) is used to compile the RC file. Then the PBRES.exe program is used to compile the .RES file created by the RC.exe program, into a .PBR file. The PBR file is what is embeded into the PB application by using the #RESOURCE compiler directive.

There are two ways to compile a resource file with the Dialog Designer. The first is to manually compile it yourself. You can simply load the RC file (found in RCDATA subfolder from where your apps source code is) into the PB IDE and then simply compile it. The IDE knows how to compile it correctly.

The second way is to have the designer autocompile it for you, whenever you regenerate your apps code.

How do I autocompile resources ?

From the Files menu of the Designer select the "Designer Options" item. This will display the "Configuration Options" dialog.

Their is a field in dialog for editing the path for the resource compiler (RC.exe). Notice in this image (see below) the small button with an UP arrow on it (circled in red). Click this button to display the Select File dialog so you can find the RC.exe file in your PB installation. The RC.exe file (resource compiler) is usually found in the BIN folder of the PB compiler.

By selecting the RC.exe file of your PB compiler and clicking the open button of the dialog, you will have selected the path to the resource compiler. Now click the Apply button in the configuration dialog and you are ready to compile resources.

The next step is to make sure the project properties for your project for resources are defined correctly.

Here are those properties:

First, if you want to autocompile the resource file for a project, set the first property:

"Auto Compile Resource"

to "1 - ON"

The next property is a path to the resource.h file that all resource files (RC) require to be defined.

"Resource Header"

Select the property and then click the small button (...) in it to display the open file dialog. Find the file resource.h in the compilers win32api folder and then click open. Now the path to this file is define. If this property is not set correctly, the resource file can not be compiled.

The next property:

"User Resource header"

need not be used, but is simply for adding an include to the apps resource file pointing to another resource file. This is how you embed resource code which was not generated by the designer.

The last property:

"Add #RESOURCE code"

must be set to "1 - Yes". This will force the designer to generate the #RESOURCE compiler directive to your apps source code, so the resource file is added to the apps when compiling.

Now for the last point about resources.

When you define resources in a project (with the "Load from EXE" option), the code generator will scan all references to images in the controls of the project for any matches to the resources you defined. If they match, the generator will modify the image loading code for the control to load the image from the resources, rather than from a disk file.

All images which are defined for controls which are not found to be loaded as resources into the EXE, as well as images in the resource section of your project which use the option "Load from disk file", will be copied from their original location to either the apps source code folder or a graphic subfolder off that folder. The following properties of a project determine where those files are copied to:

All times are EST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | Computer Workshop ( EZGUI ) Home Page

Copyright 2000 to 2007 Christopher R. Boss

Powered by: Ultimate Bulletin Board, Version 5.44
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.