[SOLVED]Changing the color without system()

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
Last edited on
I think doing a clear screen right after changing the color should work.
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?
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
Topic archived. No new replies allowed.