GreQueryColorIndex

GreQueryColorIndex returns the logical color index that is closest to the specified RGB color representation for the device. If the color index is in RGB mode, the supplied RGB value is returned.

This function must be supported by the presentation driver. GreQueryColorIndex is called by GpiQueryColorIndex when an application requests the index of the color most closely matching a specified color, relative to the current logical color table for the device context.


 * Simulation support: None. This function is mandatory for all drivers.

Syntax
GreQueryColorIndex(hdc, flOptions, rgbColor, pInstance, lFunction);

Parameters

 * hdc (HDC) - input : Device context handle.


 * flOptions (ULONG) - input : Options flag.

The only valid option is:
 * LCOLOPT_REALIZED: If set, the information is required when the logical color table (if any) is realized. Otherwise, the information is required when the logical color table is not realized.

Other flags are reserved and must be 0.


 * rgbColor (LONG) - input : Color, as an RGB value.


 * pInstance (PVOID) - input : Pointer to instance data.


 * lFunction (ULONG) - input : High-order WORD=flags; low-order WORD=NGreQueryColorIndex.

Returns

 * rc (LONG) - returns : Return Code.

On completion, the handling routine must return the color index that provides the closest match to the specified color (lColorIndex), or GPI_ALTERROR if an error occurred.

Possible Errors Detected: When an error is detected, the handling routine must call WinSetErrorInfo to post the condition. Error codes for conditions that the handling routine is expected to check include:


 * PMERR_DEV_FUNC_NOT_INSTALLED
 * PMERR_INV_COLOR_OPTIONS
 * PMERR_INV_HDC
 * PMERR_INV_RGBCOLOR

Refer to the "Error Explanations" section in the Presentation Manager Programming Reference for further explanation.

Sample

 * 1) define INCL_GRE_COLORTABLE
 * 2) include 

HDC     hdc;        /*  Device context handle. */ ULONG   flOptions;  /*  Options flag. */ LONG    rgbColor;   /*  Color, as an RGB value. */ PVOID   pInstance;  /*  Pointer to instance data. */ ULONG   lFunction;  /*  High-order WORD=flags; low-order WORD=NGreQueryColorIndex. */ LONG    rc;         /*  Return Code. */

rc = GreQueryColorIndex(hdc, flOptions, rgbColor, pInstance, lFunction);