Feb 13, 2009 at 9:16am UTC
I know how to use SetConsoleTextAttribute() to change the text foreground and background color. But was wondering how I can get the hole background to change its color. For example using system("color 1A"); to change the color but in another way. As I'd prefer not to use system.
Thanks,
Myth.
Last edited on Feb 13, 2009 at 9:42pm UTC
Feb 13, 2009 at 12:50pm UTC
Last edited on Feb 13, 2009 at 12:53pm UTC
Feb 13, 2009 at 3:06pm UTC
I think doing a clear screen right after changing the color should work.
Feb 13, 2009 at 8:35pm UTC
Trust me I had googled one to many pages, I'm more than happy to show you my history and dates of the searches if you like?
Feb 13, 2009 at 9:34pm UTC
Thanks for that helios - worked a charm. I used a function i made from the msdn a while ago.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
void ClearScreen()
{
COORD coordScreen = {0, 0};
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
return ;
}
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
if (!FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), (TCHAR) ' ' , dwConSize, coordScreen, &cCharsWritten))
{
return ;
}
if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
return ;
}
if (!FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
{
return ;
}
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordScreen);
}
Last edited on Feb 13, 2009 at 9:38pm UTC