BOOL GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy) | |||||
HDC hdc; | /* handle of device context | */ | |||
HBRUSH hbr; | /* handle of brush for graying | */ | |||
GRAYSTRINGPROC gsprc; | /* address of callback function | */ | |||
LPARAM lParam; | /* address of application-defined data | */ | |||
int cch; | /* number of characters to output | */ | |||
int x; | /* horizontal position, */ | ||||
int y; | /* vertical position, */ | ||||
int cx; | /* width | */ | |||
int cy; | /* height | */ |
The GrayString function draws gray (dim) text at the given location by writing the text in a memory bitmap, graying the bitmap, and then copying the bitmap to the display. The function grays the text regardless of the selected brush and background. GrayString uses the font currently selected for the given device context.
hdc
Identifies the device context.
hbr
Identifies the brush to be used for graying.
gsprc
Specifies the procedure-instance address of the application-supplied callback function that will draw the string. The address must be created by the MakeProcInstance function. For more information about the callback function, see the description of the GrayStringProc callback function.
If this parameter is NULL, the system uses the TextOut function to draw the string, and the lParam parameter is assumed to be a long pointer to the character string to be output.
lParam
Points to data to be passed to the output function. If the gsprc parameter is NULL, the lParam parameter must point to the string to be output.
cch
Specifies the number of characters to be output. If this parameter is zero, the GrayString function calculates the length of the string (assuming that the lParam parameter is a pointer to the string). If cch is –1 and the function pointed to by the gsprc parameter returns zero, the image is shown but not grayed.
x
Specifies the logical x-coordinate of the starting position of the rectangle that encloses the string.
y
Specifies the logical y-coordinate of the starting position of the rectangle that encloses the string.
cx
Specifies the width, in logical units, of the rectangle that encloses the string. If this parameter is zero, the GrayString function calculates the width of the area, assuming the lParam parameter is a pointer to the string.
cy
Specifies the height, in logical units, of the rectangle that encloses the string. If this parameter is zero, the GrayString function calculates the height of the area, assuming the lParam parameter is a pointer to the string.
The return value is nonzero if the function is successful. It is zero if either the TextOut function or the application-supplied output function returns zero, or if there is insufficient memory to create a memory bitmap for graying.
An application must select the MM_TEXT mapping mode before using this function.
If TextOut cannot handle the string to be output (for example, if the string is stored as a bitmap), the gsprc parameter must point to a callback function that will draw the string.
An application can draw grayed strings on devices that support a solid gray color without calling the GrayString function. The system color COLOR_GRAYTEXT is the solid-gray system color used to draw disabled text. The application can call the GetSysColor function to retrieve the color value of COLOR_GRAYTEXT. If the color is other than zero (black), the application can call the SetTextColor function to set the text color to the color value and then draw the string directly. If the retrieved color is black, the application must call GrayString to gray the text.