WriteConsoleOutputAttribute

  BOOL WriteConsoleOutputAttribute(hConsoleOutput, lpwAttribute, cWriteCells, coordWriteCoord, lpcNumberWritten)    
  HANDLE hConsoleOutput; /* identifies console screen buffer */
  LPWORD lpwAttribute; /* buffer to write attributes from */
  DWORD cWriteCells; /* number of character cells to write to */
  COORD coordWriteCoord; /* coordinates of first cell to write to */
  LPDWORD lpcNumberWritten; /* actual number or cells written to */

The WriteConsoleOutputAttribute function writes a string of foreground and background color attributes to a console screen buffer beginning at the specified location.

Parameters

hConsoleOutput

Specifies an open handle with GENERIC_WRITE access to a console screen buffer to write to.

lpwAttribute

Points to a buffer containing the attribute string to write to the screen buffer.

cWriteCells

Specifies the number of screen buffer character cells to write to.

coordWriteCoord

Specifies the column and row coordinates of the first cell in the screen buffer to write the string to.

lpcNumberWritten

Points to a DWORD that the function will set on exit to the number of attributes written to the screen buffer.

Return Value

If the function is successful, the return value is TRUE. Otherwise, it is FALSE. Extended error information can be obtained by calling the GetLastError function.

Comments

This function writes an attribute string to the screen buffer. If the number of attributes to write extends beyond the end of the specified row in the screen buffer, attributes are written to the next row. If the number of attributes to write extends beyond the end of the screen buffer, the attributes up to the end of the screen buffer are written.

Each attribute specifies the foreground and background colors in which that character cell will be drawn. The attribute values will be some combination of the color constants, such as FOREGROUND_RED or BACKGROUND_BLUE, that are defined in wincon.h.

The character values at the positions written are left unchanged.

See Also

WriteConsoleOutput, WriteConsoleOutputCharacter, ReadConsoleOutput, ReadConsoleOutputCharacter, ReadConsoleOutputAttribute