Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change entire console background color (Win32 C++)

How can I change the entire console's background color? I've tried SetConsoleTextAttribute and it only changes the background color of new text.

I effectively want the entire console to turn red when a serious error arises.

Thanks to everyone who attempts to help.

like image 890
Smurf64 Avatar asked Jun 23 '11 21:06

Smurf64


People also ask

How do I change the background color in C?

Declaration: void setbkcolor(int color); setbkcolor function changes current background color e.g. setbkcolor(YELLLOW) changes the current background color to YELLOW. Remember that default drawing color is WHITE and background color is BLACK.

How do I change the background color of my console in C ++?

If you are going to write your program for Windows and you want to change color of text and/or background, use this: SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), attr); Where attr is a combination of values with | (bitwise OR operator), to choose whther you want to change foreground or background color.

How do I change the background color in C sharp?

To change the background color of text in Console, use the Console. BackgroundColor Property in C#.


1 Answers

Try something like:

system("color c2");
like image 190
wxffles Avatar answered Sep 30 '22 05:09

wxffles