WINPRINT-SET-TEXT-COLOR

This operation code specifies the foreground color for text.

Usage

CALL "WIN$PRINTER"
    USING WINPRINT-SET-TEXT-COLOR, WINPRINT-DATA
    GIVING RESULT

Parameters

WINPRINT-DATA Group item defined in winprint.def as follows:
01 WINPRINT-DATA.
   03 WPRTDATA-SET-STD-FONT.
   03  WPRTDATA-TEXT-COLOR REDEFINES
       WPRTDATA-SET-STD-FONT.   PIC 9(9) COMP-5.

Return Values

This option returns text color prior to the change. Use this value to restore a temporary change.

Description

When printing, color resolution is a result of a combination of three basic colors; Red, Green, and Blue (RGB). The intensity of each color in the mix is determined by a number between 0and 255. For example, the lowest possible intensity, (0,0,0), produces black, and the highest possible intensity (255,255,255), produces white. This formula of three numbers is referred to as the COLORREF.

The ACUCOBOL-GT runtime does not provide a mechanism with which to determine the COLORREF. If you want to specify a color, you must calculate the value yourself. The following C formula can be used to calculate the COLORREF:

(((BYTE) (R) | ((WORD) (BYTE 9g)) <<8))|(((DWORD) (BYTE) (b)) <<16))

See your Windows API documentation for more information about RGB colors and COLORREF values.

The printer must be open to perform this operation. There is no need to reset this function. WPRTDATA-TEXT-COLOR should be initialized prior to use. This operation affects the color used with subsequent WRITE statements. Cursor position is not affected by this operation. This operation is ignored on non-color printers. WINPRINT-SET-TEXT-COLOR has the following value:

WPRTDATA-TEXT-COLOR Specifies the color used to write text. The color is indicated by the COLORREF, representing the percentage used of the three basic colors; Red, Green, and Blue (RGB). The default of 0 is solid black.

Example

This example will set the current text foreground color to light blue when printed on a color printer:

INITIALIZE WPRTDATA-TEXT-COLOR.
MOVE 96 TO RGB-RED.
MOVE 106 TO RGB-GREEN.
MOVE 232 TO RBG-BLUE.
PERFORM CALC-COLORREF.
MOVE COLORREF TO WPRTDATA-TEXT-COLOR.
CALL "WIN$PRINTER" USING
     WINPRINT-SET-TEXT-COLOR
     WPRTDATA-TEXT-COLOR
     GIVING CALL-RESULT.

The sample program graphprn.cbl contains an example of using the C formula described above to determine the RGB color value (CALC-COLORREF).