FillConsoleOutputAttribute

  BOOL FillConsoleOutputAttribute(hConsole, wAttribute, cCharCells, coordAttr, lpcWritten)    
  HANDLE hConsole; /* screen buffer handle to write to */
  WORD wAttribute; /* color attribute to write */
  DWORD cCharCells; /* number of character cells to write to */
  COORD coordAttr; /* x and y coordinates of first cell */
  LPDWORD lpcWritten; /* receives number of cells written to */

The FillConsoleOutputAttribute function sets the foreground and background color attributes for a specified number of character cells beginning at the specified coordinates in a screen buffer.

Parameters

hConsole

Specifies an open handle to a screen buffer (CONOUT$). The handle must have been created with GENERIC_WRITE access.

wAttribute

Specifies the foreground and background color attributes to write to the screen buffer. Constants defined in wincon.h may be combined to create different colors. For example, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE will result in white text.

cCharCells

Specifies the number of character cells to be set to the specified color attributes.

coordAttr

Specifies a COORD structure containing the screen buffer coordinates of the first cell whose attributes are to be set.

The COORD structure has the following format:

typedef struct _COORD { /* coord */

SHORT X; /* horizontal coordinate */

SHORT Y; /* vertical coordinate */

} COORD, *PCOORD;

lpcWritten

Points to the variable that will receive the number of characters whose attributes were actually set.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

If the number of character cells whose attributes are to be set extends beyond the end of the specified row in the screen buffer, the cells of the next row are set. If the number of cells to write extends beyond the end of the screen buffer, the cells up to the end of the screen buffer are written.

The character values at the positions written are left unchanged.

See Also

FillConsoleOutputCharacter, SetConsoleTextAttribute, WriteConsoleOutputAttribute