GUI ScreenIO for Windows

 ScreenIO.com


Defining Named Colors

GUI ScreenIO allows you to define color combinations in the panel editor that you can then refer to by name in your program when you want to change the color of a control, or of an individual item in a listview control on the fly.

You can also save your custom color definition to a file so that you can use them consistently in all of your panels.

Important:  Be sure to see the section on Colors and Video Modes, below!

For example, you can select a background color of yellow with a foreground (text) color of red and name it something like "MY-WARNING-COLOR".  Then, in your program when you want to change the color of a control, you simply move MY-WARNING-COLOR to the control's color attribute.

This makes it a snap to change colors of things at runtime, without getting into the complexities of assigning the standard Windows 24-bit color value to an item.

Start by selecting Panel/Named Color List from the main menu.  You'll get a panel that looks like this:

Right-click in the Color Name area, and select Add New Color from the context menu.  This will place an UNNAMED item into the list.  You can now assign your own name to the color by clicking the item to select it, pausing, then clicking it again.  Enter the COBOL name of the color.

Now, right-click the item and select "Background color" from the context menu.  You'll be presented with the standard Windows color dialog.  It looks like this: 

Choose the background color you want, then right-click the color item to choose a foreground (text) color.  In the illustration below, we've defined a couple of colors.  As you can see, the list shows not only the name of the color you defined, but what it looks like.

Colors and Video Modes

There are a few things you need to be aware of when you start assigning colors.  For example, if your development machine is running 24-bit (True) color, and you select a color that cannot be rendered precisely on an end-user's computer that is running only 256 colors, things aren't going to look the same.

Windows will do its best to approximate the color, but it will still be an approximation, not the exact color that you chose.

Therefore, we strongly recommend that you run your development machine in the same video mode as the lowest-resolution/number-of-colors machine that one of your end users is likely to have.  Otherwise, you're going to receive complaints about your color scheme.

Dithering

The color dialog above shows that we've selected a nice shade of blue, but in the sample box, it shows two different colors.  One says "Color" and the other says "Solid".  What's that all about?

Well, the "Color" sample shows the closest rendition of the color that you selected that it can, for the computer that you're running on.  The computer we used to create this sample is running 256 color mode.  Since the color that we selected cannot be shown as a pure color in 256 color mode, Windows attempts to render it by dithering.  This is a simple matter of mixing pixels of different colors to approximate the color that you chose.  Your eye blends the colors so that it appears (sort of) as a solid color that approximates the one the designer selected.

Note:  Windows applies dithered colors to backgrounds, but not to text.

The "Solid" color is the closes non-dithered color to the one that you chose.  Windows will use this color when it paints text in your application.

Note that, if you choose a background color that is dithered, text may be difficult to read.  So, in general, you should avoid colors that will be dithered.

You can select "pure" colors by typing the Red-Green-Blue values manually.  For example, a color that is defined as Red:255, Green:0, Blue:0 is pure Red.  If all of the colors are 255, the result is White, and if they're all 0, the result is Black. 

If you specify other than 255, the color is not as intense; for example, a Red value of 127 results in a very dark shade of red. 

The conclusion?  Be careful about the colors you select; stick with solid colors as much as you can, and be sure to test your color scheme with all of the video modes that your application is likely to run on.  You'll be happy you did. 

Related topics:


© 2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom