I was wondering if anyone knows how to change the color/background color of static text. Any help, or examples would be appreciated. Thanks!!
I was wondering if anyone knows how to change the color/background color of static text. Any help, or examples would be appreciated. Thanks!!
If you're using a windows compiler simply use
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), c);
where c is the color.
there are 16 possible colors for the foreground and other possibilites for the background.
Foreground
BLACK
BLUE
GREEN
CYAN
RED
MAGENTA
BROWN
LIGHTGRAY
DARKGRAY
LIGHTBLUE
LIGHTGREEN
LIGHTCYAN
LIGHTRED
LIGHTMAGENTA
YELLOW
WHITE
Background colors can be intensified, brigtened to make lighter shades out of the colors for example, BACKGROUND_BLUE, can be made lightblue by BACKGROUND_BLUE | BACKGROUND_INTENSITY
remember, you cannot declare the following colors as backgrounds
LIGHTGRAY,DARKGRAY,LIGHTBLUE,LIGHTGREEN,LIGHTCYAN, LIGHTRED,LIGHTMAGENTA,YELLOW,WHITE,CYAN,MAGENTA,BR OWN,BLACK
However you can make most of the colors with the right combinations the exceptions DARKGRAY and BLACK.
Here are the combinations for the colors
WHITE-BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY
LIGHTGRAY-BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
LIGHTBLUE-BACKGROUND_BLUE | BACKGROUND_INTENSITY
LIGHTRED-BACKGROUND_RED | BACKGROUND_INTENSITY
LIGHTCYAN-BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY
LIGHTRED-BACKGROUND_RED | BACKGROUND_INTENSITY
LIGHTMAGENTA-BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY
YELLOW-BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY
BROWN -BACKGROUND_RED | BACKGROUND_GREEN
MAGENTA-BACKGROUND_BLUE | BACKGROUND_RED
CYAN-BACKGROUND_BLUE | BACKGROUND_GREEN
This is only the EGA textmode, remember if you are using windows based compilers you are confined to EGA textmode.
Last edited by Eric08; 07-06-2003 at 06:06 AM.