short Escape(hDC, SETCOLORTABLE,sizeof(COLORTABLE_STRUCT), lpInData,lpColor)
This escape sets an RGB color-table entry. If the device cannot supply the exact color, the function sets the entry to the closest possible approximation of the color.
Parameter | Type/Description |
hDC | HDC Identifies the device context. | |
lpInData | COLORTABLE_STRUCT FAR * Points to a COLORTABLE_STRUCT data structure that contains the index and RGB value of the color-table entry. See the following “Comments” section for more information on the COLORTABLE_STRUCT data structure. | |
lpColor | DWORD FAR * Points to the long-integer value that is to receive the RGB color value selected by the device driver to represent the requested color value. |
The return value specifies the outcome of the escape. It is positive if the escape is successful. Otherwise, it is negative.
The COLORTABLE_STRUCT data structure has the following format:
typedef struct {
WORD Index;
DWORD rgb;
} COLORTABLE_STRUCT;
This structure has the following fields:
Field | Description |
Index | Specifies the color-table index. Color-table entries start at zero for the first entry. |
rgb | Specifies the desired RGB color value. |
A device's color table is a shared resource; changing the system display color for one window changes it for all windows. Only applications developers who have a thorough knowledge of the display driver should use this escape.
The SETCOLORTABLE escape has no effect on devices with fixed color tables.
This escape is intended for use by both printer and display drivers. However, the EGA and VGA color drivers do not support it.
This escape changes the palette used by the display driver. However, since the driver's color-mapping algorithms will probably no longer work with a different palette, an extension has been added to this function.
If the color index pointed to by the lpInData parameter is 0XFFFF, the driver is to leave all color-mapping functionality to the calling application. The application must use the proper color-mapping algorithm and take responsibility for passing the correctly mapped physical color to the driver (instead of the logical RGB color) in such device-driver functions as RealizeObject and ColorInfo.
For example, if the device supports 256 colors with palette indexes of 0 through 255, the application would determine which index contains the color that it wants to use in a certain brush. It would then pass this index in the low-order byte of the DWORD logical color passed to the RealizeObject device-driver function. The driver would then use this color exactly as passed instead of performing its usual color-mapping algorithm. If the application wants to reactivate the driver's color-mapping algorithm (that is, if it restores the original palette when switching from its window context), then the color index pointed to by lpInData should be 0xFFFE.