GpiQueryRGBColor
Appearance
This function returns the actual RGB color that results from a particular index on the currently-associated device.
Syntax
GpiQueryRGBColor(hps, flOptions, lColorIndex)
Parameters
- hps (HPS) - input
- Presentation-space handle.
- flOptions (ULONG) - input
- Options.
- LCOLOPT_REALIZED
- If this is specified, the information is required for when the logical color table is realized.
- If it is not specified (flag is not set) the information is required for when the logical color table (if any) is not realized.
- Other bits are reserved, and must be 0.
- lColorIndex (LONG) - input
- Color index.
- This can be any normally valid color index value (see GpiSetColor) except CLR_DEFAULT. When using the system color table, it can also be any SYSCLR_* value.
Return Value
- lRgbColor (LONG) - returns
- RGB color providing closest match to the specified color index.
- >=0
- RGB color providing closest match
- GPI_ALTERROR
- Error.
Remarks
If an RGB logical color table has been loaded, this function returns the nearest RGB color. This function is then equivalent to GpiQueryNearestColor.
Errors
Possible returns from WinGetLastError:
- PMERR_INV_HPS (0x207F)
- An invalid presentation-space handle was specified.
- PMERR_PS_BUSY (0x20F4)
- An attempt was made to access the presentation space from more than one thread simultaneously.
- PMERR_INV_COLOR_OPTIONS (0x2057)
- An invalid options parameter was specified with a logical color table or color query function.
- PMERR_INV_COLOR_INDEX (0x2056)
- An invalid color index parameter was specified with GpiQueryRGBColor.
Example Code
#define INCL_GPILOGCOLORTABLE /* Or use INCL_GPI, INCL_PM, */ #include <os2.h> HPS hps; /* Presentation-space handle. */ ULONG flOptions; /* Options. */ LONG lColorIndex; /* Color index. */ LONG lRgbColor; /* RGB color providing closest match to the specified color index. */ lRgbColor = GpiQueryRGBColor(hps, flOptions, lColorIndex);
This example uses the GpiQueryRGBColor call to determine if the color white is available.
#define INCL_GPILOGCOLORTABLE #include <OS2.H> LONG lResult; /* closest match to the specified index */ HPS hps; /* Presentation space handle. */ ULONG flOptions; /* options */ LONG lColorIndex; /* color index */ lColorIndex = CLR_WHITE; flOptions = LCOLOPT_REALIZED; /* information is required for when the */ /* logical color table is realized. */ lResult = GpiQueryRGBColor(hps, flOptions, lColorIndex );