Jump to content
  • Advertisement
Sign in to follow this  
Rhaal

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.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by xMcBaiNx
MSDN


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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by RenderTarget
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.


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 this post


Link to post
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

adding intensity makes a brighter shade of each:

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 this post


Link to post
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..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!