Creating the application resource file

A resource file consists of string and binary data. These entries are identified by an ID, which we use within Visual Basic to load the resource. The string details can be anything textual, such as filenames or messages that are to be used in the application.

The following is the resource file that is used with the spoken help application:

// This is the Resource file for the spoken help project.
// It contains the path and name of all of the
// multimedia clips used in the application.

STRINGTABLE

BEGIN
//Spoken Help Path and File details
    1001 "\wav\mdifile.wav"
    1002 "\wav\mdiform.wav"
    1003 "\wav\index.wav"
    1004 "\wav\packview.wav"
    1005 "\wav\packexit.wav"
    1006 "\wav\narrdesc.wav"
    1007 "\wav\narrexit.wav"
    1008 "\wav\mditools.wav"
    1009 "\wav\mdihelp.wav"
    1010 "\wav\mdiform.wav"

    //Product text
    5001 "This is the Microsoft Art Gallery Product. It has details of " &
         "pictures from the Art Galleries in London"

END

// The non-string data follows...

    Art1 BITMAP  atopen.bmp

Resource files are an efficient means of using string and picture data because they are compiled and usually loaded only on request. If you’re writing a heavyweight application that is very resource hungry, this might be one method to make it slightly more Windows-friendly and economical in its use of resources.

For the sample application, we’ll use the string section to hold the details of software products and the partial path and filename of the WAV files. The application path will be appended to these paths to produce the full path for the file. (This will enforce a sensible directory structure on the application and—more important—will ensure that absolute paths are not coded into the application.) To demonstrate its other textual function, it also shows a description of the product. For demonstration purposes, there’s only one product, so there’s only one entry (5001).

For the pictures of the products, it uses the bitmap data type. This holds a pointer to the bitmap details when the file is compiled rather than holding the actual bitmap image.

As you can see by these details, the string details are held in an area called the STRINGTABLE. These string resources start with a numeric ID, followed by the actual string. For data resources, you can create nonnumeric IDs, although there are some documented limitations. The only entry for this sample application is the bitmap that will be displayed when you load the Fine Art details.