Platform SDK: Files and I/O

FillConsoleOutputAttribute

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

BOOL FillConsoleOutputAttribute(
  HANDLE hConsoleOutput,          // handle to screen buffer
  WORD wAttribute,                // color attribute
  DWORD nLength,                  // number of cells
  COORD dwWriteCoord,             // first coordinates
  LPDWORD lpNumberOfAttrsWritten  // number of cells written
);

Parameters

hConsoleOutput
[in] Handle to a screen buffer. The handle must have GENERIC_WRITE access.
wAttribute
[in] Specifies the foreground and background color attributes to write to the screen buffer. Any combination of the following values can be specified: FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following combination of values produces white text on a black background:
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE 
nLength
[in] Specifies the number of character cells to be set to the specified color attributes.
dwWriteCoord
[in] Specifies a COORD structure containing the screen buffer coordinates of the first cell whose attributes are to be set.
lpNumberOfAttrsWritten
[out] Pointer to the variable that receives the number of character cells whose attributes were actually set.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

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 to extends beyond the end of the screen buffer, the cells are written up to the end of the screen buffer.

The character values at the positions written to are not changed.

Requirements

  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Wincon.h; include Windows.h.
  Library: Use Kernel32.lib.

See Also

Consoles and Character-Mode Support Overview, Console Functions, COORD, FillConsoleOutputCharacter, SetConsoleTextAttribute, WriteConsoleOutputAttribute