INF: Changing the Palette of Colors on NonPalette Devices

ID Number: Q62740

2.03 2.10 3.00

WINDOWS

Summary:

This article discusses changing the colors that Windows uses and

specifically addresses the following:

1. Displaying 16 gray shades on a standard VGA screen in an application

that renders gray-scale bitmaps under Windows.

2. Selecting 16 nondefault colors for a display in the VGA and EGA

16-color drivers.

For devices that have a modifiable color palette, you can implement

the SETCOLORTABLE escape in the device driver to allow applications to

choose the desired colors. Note, however, that the display drivers

(EGA, VGA, and so on) that Microsoft provides do not support this

escape. You must write a custom driver to support this type of

functionality. The application should send the QUERYESCSUPPORT escape

to the driver to determine whether the escape is supported.

Note: The implementation and use of the SETCOLORTABLE escape in

display drivers affects all windows that are displayed. Because

changing the color table can adversely affect the appearance of normal

window attributes, such as caption bars or window frames, use of this

functionality is not recommended. SETCOLORTABLE should be used only

after considering how it will affect the user interface for all

applications.

Windows version 3.0 introduced a set of palette mapping functions that

allow the application to choose what colors are to be available in the

hardware palette when the application is active. However, these

functions work only with devices that support 256 or more colors, and

that have drivers designed for palette support. For 16-color devices,

the SETCOLORTABLE escape is the only possibility. However, as noted

above, the drivers provided with Windows do not support this

functionality.

If a driver supports the color palette management functions, Windows

reserves 20 colors for use of normal window attributes, such as

caption bars and window frames. Thus, changes to the color palette do

not affect the normal aspects of the Windows user interface. If it is

absolutely essential to the application, these reserved colors can be

overridden by using the SetSystemPaletteUse function. However, using

this function risks ruining the appearance of other windows' colors.

If the display device supports more than 16 colors and you want to

support this escape, or if you want to add this functionality to the

standard EGA, VGA, or other driver, either order a copy of the Windows

Device Driver Kit (DDK) and modify an existing driver, or write a new

driver.