GUI ScreenIO for Windows

 ScreenIO.com


Resources

Resources are data that is stored in binary form in your application's executable file.  GUI ScreenIO can load bitmaps and icons from resources you've linked into your executable. 

The splash screen displayed when you launch the GUI ScreenIO panel editor is a bitmap resource that's linked into GS2000.EXE, the panel editor executable.

WARNING:

Resources are not compatible with the Client/Server layer.  Images or Icons you embed in your application via this method will not appear on the Client Side.  External images (images in files, BMP, Jpg, Png, etc) all work seamlessly over the client server layer, but resources are handled by windows directly, and they reside in the your .EXE and as such are not available to the Client.

Having Resources attached to a Client/Server application is permissible, but the images will not show up on the client side and will be replaced by the big red X image.

Basic Steps:

It's easy to include icons and bitmaps in your executable.  Here's how:

  1. Create the icon and/or bitmap files.
  2. Create a resource script that tells the resource compiler which resources are to be included, and their names.
  3. Compile the resources into a binary resource file.
  4. Convert the resource file to object form.
  5. Link the resource with your application.

Create the resources

Images (.BMP)

You can use Windows Paint to create bitmaps.

Bitmap resources must be standard bitmaps; you can't use JPEG, GIF, or other forms of image files. 

Bear in mind that bitmaps are not compressed, and can be quite large.  For example, a 640x480 bitmap that uses 32 bit color will add over a megabyte(!) to the size of your .EXE file.

If you include large images in your executable, they will increase the size of your .EXE file considerably. 

Icons (.ICO)

We used Microsoft ImagEdit to create the icons used in GUI ScreenIO.  ImagEdit is distributed with many Microsoft software development products.  You can also obtain third-party icon editors from a variety of sources; do an Internet search on "icon editor" and you'll find plenty to choose from.

You can also find thousands of icon files on the Internet if you prefer not to create your own.

The resource script

A resource script is just a small text file that tells the resource compiler which files are to be included in the resource file, as well as the type of resource they are.  It also assigns a name to the resource; the name is used to identify the resource when GUI ScreenIO loads it.

Here's a resource script that will include an icon and a bitmap in a resource file.  The resource script file must have the extension .RC. 

It's customary to give your resource file the same name as your application, so if our application is named myapp.exe, we'd name this file myapp.RC.

myapp      ICON    myapp.ICO
myimage    BITMAP  mypic.BMP

myapp is the name used to identify the icon resource from the icon file myapp.ICO, and myimage is the name used to identify the bitmap from the file mypic.BMP.  The names are not case-sensitive, and do not need to match the names of their source files.

ICON and BITMAP specify the type of resource.

Displaying an icon in the title bar

If your icon has the same name as your executable, the icon will be displayed in the title bar when you run your application.  If your application is named myapp.exe, your resource script would contain this icon statement:

myapp      ICON    myapp.ICO

Compiling the resources

Most 32-bit COBOL compilers include RC.EXE, the Microsoft Resource Compiler.  This program compiles your resources into a resource file. 

You can get instructions for running RC.EXE by entering this command:

RC/?

The resource compiler requires a script file and your icon files as input. 

Now, issue this command:

RC myapp.RC

where RC is the command for RC.EXE, and myapp.RC is the name of your script file.

The resource compiler will create a binary resource file myapp.RES.  It's the same name as the script file, but with a .res extension.

Converting the resource file to object format

The binary resource file from the previous step is not compatible with the Microsoft Linker, so it needs to be created to COFF (Common Object File Format) in order to be linked into your executable. 

This is done using the Microsoft application CVTRES.EXE, which should also be included with your COBOL compiler.

The command to convert the file is:

CVTRES /out:myapp.rbj /machine:ix86 myapp.res

where CVTRES is the command, /out:myapp.rbj specifies the name of the output file, /machine:ix86 specifies the output format, and myapp.res is the input file from the previous step.

The binary resource file may be included in an object library like any other object file.

Linking the resource file with your application

Now, link the module myapp.RBJ with your executable, just as you would any other object file.  You'll need to include it explicitly, like this:

link myapp.rbj   ...other LINK arguments

If you create a shortcut to your executable, you'll see your icon on the desktop.

Related topics:


2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom