I am trying to write a program that will output via coordinates. I am using the windows.h include, and the function WriteConsoleOutputCharacter to print characters to the screen, however it ignores the color set by SetConsoleTextAttribute. Any ideas how to get it to output in color?
Code outputting to the console:
void Card::printFancy(COORD coord, bool top) const
{
paint();
LPDWORD written(0);
for (int row(0); row < CARD_WIDTH; ++row)
{
coord.Y += 1;
WriteConsoleOutputCharacter(Colorizer::getInstance().getCon(), _card[row], CARD_WIDTH, coord, written);
}
unpaint();
}
And paint basically calls a paint function in my Colorizer class with the appropriate color
Colorizer paint function (called by paint() and unpain():
void paint(uint color)
{
SetConsoleTextAttribute(_con, color);
}
_con is the handle, set via _con = GetStdHandle(STD_OUTPUT_HANDLE);
It is the counterpart of WriteConsoleOutputAttribute(). One writes a character but doesn’t change the attribute. The other writes the attribute but doesn’t change the character.
Use WriteConsole() instead.