Jump to content

GpiQueryColor

From EDM2
Revision as of 22:23, 6 April 2025 by Iturbide (talk | contribs) (Created page with "This function returns the current value of the (character) color attribute, as set by the GpiSetColor call. ==Syntax== GpiQueryColor(hps) ==Parameters== ; hps (HPS) - input : Presentation-space handle. ==Return Value== ; lColor (LONG) - returns : Color attribute. : If the presentation space is in RGB mode, lColor is an RGB value for the background. If the presentation space is in index mode (as set through GpiCreateLogColorTable), lColor is a CLR_* index...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function returns the current value of the (character) color attribute, as set by the GpiSetColor call.

Syntax

GpiQueryColor(hps)

Parameters

hps (HPS) - input
Presentation-space handle.

Return Value

lColor (LONG) - returns
Color attribute.
If the presentation space is in RGB mode, lColor is an RGB value for the background. If the presentation space is in index mode (as set through GpiCreateLogColorTable), lColor is a CLR_* index value.
CLR_ERROR
Error
CLR_DEFAULT
Default
Otherwise
Color index.

Remarks

This function is invalid when the drawing mode (see GpiSetDrawingMode) is set to retain. Valid CLR_* values are listed in the following list:

CLR_BACKGROUND (0L)
CLR_BLUE (1L)
CLR_RED (2L)
CLR_PINK (3L)
CLR_GREEN (4L)
CLR_CYAN (5L)
CLR_YELLOW (6L)
CLR_NEUTRAL (7L)
CLR_DARKGRAY (8L)
CLR_DARKBLUE (9L)
CLR_DARKRED (10L)
CLR_DARKPINK (11L)
CLR_DARKGREEN (12L)
CLR_DARKCYAN (13L)
CLR_BROWN (14L)
CLR_PALEGRAY (15L)

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_IN_RETAIN_MODE (0x208C)
An attempt was made to issue a function (for example, query) that is invalid when the actual drawing mode is not draw or draw-and-retain.
PMERR_INV_DC_TYPE (0x2060)
An invalid type parameter was specified with DevOpenDC, or a function was issued that is invalid for a OD_METAFILE_NOQUERY device context.

Example Code

#define INCL_GPIPRIMITIVES /* Or use INCL_GPI, INCL_PM, Also in COMMON section */
#include <os2.h>

HPS  hps;    /* Presentation-space handle. */
LONG lColor; /* Color attribute. */

lColor = GpiQueryColor(hps);

This example uses GpiQueryColor to return the current value of the (character) color attribute, then sets the color to red by calling GpiSetColor. When finished with red, the color is set back to its original value.

#define INCL_GPIPRIMITIVES /* Primitive functions */
#include <os2.h>

LONG lColor; /* current character color (or error) */
HPS hps; /* Presentation-space handle */

/* query current color */
lColor = GpiQueryColor(hps);

/* set color to red */
GpiSetColor(hps, CLR_RED);

.
.
.

/* restore to original color */
GpiSetColor(hps, lColor);