Public Group

# SetConsoleTextAttribute

This topic is 5127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is there a list somewhere of all the foreground/background colors possible using the MS Console function SetConsoleTextAttribute?

##### Share on other sites
Quote:
 Original post by xMcBaiNxMSDN

Please read my question before immediately pasting an MSDN link. Where do you think I got the function from?

I'm asking for a list of all possible colors as in yellow, purple, gold, etc...

##### Share on other sites
I don't use the SetConsoleTextAttribute too much, but don't you just use the | operator to combine colors? Like, (Console_Red | Console_Blue) would make purple? (I know Console_Red and Console_Blue aren't actually the colors, but you get the idea)

EDIT: fixed usage of vocabulary (| isn't an OR operator...)

##### Share on other sites
Back to the MSDN page, click on the "Character attributes" parameter. There's the list of colors. And yes, you | them together to make secondaries and combine fore and background colors.

##### Share on other sites
Quote:
 Original post by RenderTargetBack to the MSDN page, click on the "Character attributes" parameter. There's the list of colors. And yes, you | them together to make secondaries and combine fore and background colors.

Oh my god.

I am familiar with MSDN, so links there will not really help. Maybe the beginners forum was a bad place for me to post.

I know if you set the bits FOREGROUND_RED | FOREGROUND_BLUE, you'll get purple, and I know how to use intensity.

My question is this. Obviously SetConsoleTextAttribute has been around for a while, and SOMEBODY has had to come up with all the possible combitations between

FOREGROUND_RED
FOREGROUND_GREEN
FOREGROUND_BLUE
FOREGROUND_INTENSITY

I simply want a list. I've already come up with quite a few myself (Gold, Cyan, Bright R|G|B, Light blue, etc...) but I want to make sure I'm not missing any.

I guess when I get home from work I'll paste all the ones I have. Sorry to be confusing in my initial question. I didn't think it was gonna be this misconstrued ;)

##### Share on other sites
Ooooooooh. Gotcha. It's just like adding RBG colors:

red + green = dark yellow
red + blue = dark magenta
green + blue = dark cyan
red + green + blue = gray

red + green + intense = yellow
red + blue + intense = magenta
green + blue + intense = cyan
red + green + blue + intense = white

It used to be (in DOS days) that background colors didn't have bright versions but I'm not sure anymore. That was a limitation of the video character format (they needed room for a blinky bit).

##### Share on other sites
	switch(cl)	{	  case GREY:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN); break; }	  case WHITE:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY); break; }	  case RED:		{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_RED);break; }  	  case GREEN:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_GREEN); break; }  	  case BLUE:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_BLUE); break; }	  case PURPLE:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_RED | FOREGROUND_BLUE); break; }	  case CYAN:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_GREEN | FOREGROUND_BLUE); break; }	  case BRIGHT_RED:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_RED | FOREGROUND_INTENSITY); break; }	  case BRIGHT_GREEN:{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_GREEN | FOREGROUND_INTENSITY); break; }	  case BRIGHT_BLUE:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_BLUE | FOREGROUND_INTENSITY); break;}		  case YELLOW:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY); break; }	  case GOLD:	{ SetConsoleTextAttribute(ScreenBuffer, FOREGROUND_RED | FOREGROUND_GREEN); break; }	}

That's all the foregrounds I could come up with.

Edit: Ah I see a couple missed..

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 10
• 12
• 20
• 12
• 13
• ### Forum Statistics

• Total Topics
632148
• Total Posts
3004450

×