how to set entire console window background color with given RGB(SetConsoleScreenBufferInfoEx)?
-
I'm struggling at how to customize the console window background color. I have found that SetConsoleScreenBufferInfoEx may help me, but I don't know how to do it. I want to customize the background color like the properties window do. Anybody can help me?enter image description here And now what I have is customize the foreground color with RGB, here is my code:
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFOEX csbiInfo;
csbiInfo.cbSize = sizeof(csbiInfo);
GetConsoleScreenBufferInfoEx(hStdout, &csbiInfo);
csbiInfo.ColorTable[6] = RGB(200, 255, 0);
SetConsoleScreenBufferInfoEx(hStdout, &csbiInfo);
SetConsoleTextAttribute(hStdout, 6);The more I do, the more I can do!
-
I'm struggling at how to customize the console window background color. I have found that SetConsoleScreenBufferInfoEx may help me, but I don't know how to do it. I want to customize the background color like the properties window do. Anybody can help me?enter image description here And now what I have is customize the foreground color with RGB, here is my code:
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFOEX csbiInfo;
csbiInfo.cbSize = sizeof(csbiInfo);
GetConsoleScreenBufferInfoEx(hStdout, &csbiInfo);
csbiInfo.ColorTable[6] = RGB(200, 255, 0);
SetConsoleScreenBufferInfoEx(hStdout, &csbiInfo);
SetConsoleTextAttribute(hStdout, 6);The more I do, the more I can do!
After a bit of experimentation I found that setting the background colour and then sending a clear screen (cls command) will set the entire background to the selected colour. The only bit I cannot find, is how to send a clear screen command from code. In the old ANSI.SYS days it was done by
<ESC>[2J
, but that does not seem to work in command.com windows. However by adding asystem("cls")
call I can get the entire screen to the new colour. The following code sets the background to white.SetConsoleTextAttribute(hStdout, BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_GREEN);
system("cls");Use the best guess
-
After a bit of experimentation I found that setting the background colour and then sending a clear screen (cls command) will set the entire background to the selected colour. The only bit I cannot find, is how to send a clear screen command from code. In the old ANSI.SYS days it was done by
<ESC>[2J
, but that does not seem to work in command.com windows. However by adding asystem("cls")
call I can get the entire screen to the new colour. The following code sets the background to white.SetConsoleTextAttribute(hStdout, BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_GREEN);
system("cls");Use the best guess
How to customize the color with RGB ? This is the real question.
-
How to customize the color with RGB ? This is the real question.
I don't think you can; the function accepts any combination of the single values
[ RED | GREEN | BLUE ]
which allows up to 8 colours (16 if you add the highlight flag). If you want full colour control then you should be looking to use a proper Windows application which lets you use the complete range of RGB values.Use the best guess