Welcome!

PowerBuilder Authors: Chris Pollach, Yeshim Deniz, Jayaram Krishnaswamy, Kevin Benedict, Avi Rosenthal

Related Topics: PowerBuilder

PowerBuilder: Article

High-Color Images in PowerBuilder

Giving your PowerBuilder applications the Windows XP look

I recently completed a new major upgrade to PBDelta, which included updating all the icons to a Windows XP look and feel. This article explains some of the gotchas involved in using high-color icons with PowerBuilder and how to avoid or work around them.

At the end I'll explain how I created the icons for PBDelta v5 and provide a few links to some important articles explaining the Windows XP look and feel.

Windows XP Icons
Table 1 shows examples that compares the old style icons with the new Windows XP icons.

As you can see from the examples, the new icons are a little easier on the eye. To produce images with the new look you need a lot more than the basic 16 colors used for the old style icons. This means we need to use a file format that supports more than 16 colors and that PowerBuilder fully supports. This is where it gets a little tricky; you will notice I said, "that PowerBuilder fully supports" and I will explain why shortly.

PowerBuilder Image Formats
PowerBuilder supports multiple image file formats, including bmp, gif, ico, and jpeg. These file formats can be used throughout the many objects and controls that support images within PowerBuilder. The PowerBuilder objects/controls where these image types are mainly used are:

  • Application object
  • DataWindow objects
  • List view controls
  • Menu (toolbars) objects
  • Treeview controls
However, not all controls support all formats fully and there are inconsistencies between what you see in the development environment and what you'll see when the application is executed. I'll explain each control in turn and show the results of the various image formats.

Test Files
Although I discovered the best way to work with images in PowerBuilder while developing PBDelta under PowerBuilder 8, I have built a test harness using PowerBuilder 10 to demonstrate the various scenarios we will discuss. The test harness is a simple precanned PowerBuilder sample MDI application. I also took the basic windows folder icon and created the same image in a number of different file formats listed in Table 2. Using the application and the various image formats I'll explain which types work best with which controls.

Menu (Toolbar) Objects
I'll start with the Menu object, as this tends to be where the majority of images are used as they specify the toolbar images. On the test harness I've added an icon to the close menu item. I added each image in turn and have included a snapshot from the development environment as well as the runtime.

As you can see from Table 2, the bmp files look fine in the development environment but at runtime the colors become pale. The gif file doesn't show its transparency in the development environment but the transparency does work at runtime, but again it suffers from the pale colors. The 8-bit ico file works fine in development and on some machines it works fine at runtime; however, during testing on other machines you sometimes get a weird color effect, as shown. Finally the ico 24-bit - this looks fine in development and fine at runtime and during testing the weird test pattern effect never occurred.

I've also included the file sizes on the table so you can see that there's not much difference between the file sizes, with the ico 24-bit the second smallest. However, my testing using PowerBuilder 8 through 10 has shown that the ico 24-bit is the only file format to use for toolbar icons.

Listview Control
For the Listview control I set up a Listview using all four images at once (see Figure 1). As you can see the icons display fine for all four file types.

Treeview Control
For the Treeview control I set up a Treeview using all four images at once (see Figure 2).

The tree control works fine with all four image formats in development and runtime on my development machine; however, during testing the 256 ico file was showing a weird pattern at runtime on some machines.

DataWindow Objects
Of the four file formats, the DataWindow supports only the bmp and gif; however, as you can see from Figure 3 the bmp does not support transparency.

Therefore, the gif file format is the best for DataWindow as it's the only file format support by the DataWindow engine that supports transparency as part of the file format.

More Stories By Ken Howe

Ken Howe is a technical consultant working for Marconi Software Solutions in the UK.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.