Jump to content
  • Advertisement
Sign in to follow this  
Grahf750

C++ color console define

This topic is 4851 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

I have looked on google for a little bit but I can't find anything on changing the color of text or other ascii symbols in a console progect. If you ahve a link you could pots or tell me how here that would be great thanks.

Share this post


Link to post
Share on other sites
Advertisement
There is no standard way to do this in C++. You'll have to let us know what OS you are using. If it's windows, the info can probably be found at MSDN

Share this post


Link to post
Share on other sites
My teammate already knows of that way to do colors but he wants to use some #define 0x0ff01 type of colors he says those are better I really have no idea. Anybody know where info on that is?

Share this post


Link to post
Share on other sites
I don't do windows specific dev, hopefully someone here can help. But if you have a good relationship with your teammate, have you considered asking him why he thinks they're better?

Share this post


Link to post
Share on other sites
With the #define you can define each indivdual color, yellow, green , blue, brown, etc. instead of doing the 3 colors and intensity combination.

Share this post


Link to post
Share on other sites
Quote:
Original post by Grahf750
With the #define you can define each indivdual color, yellow, green , blue, brown, etc. instead of doing the 3 colors and intensity combination.


ripped from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/char_info_str.asp ...


FOREGROUND_BLUE 0x0001 Text color contains blue.
FOREGROUND_GREEN 0x0002 Text color contains green.
FOREGROUND_RED 0x0004 Text color contains red.
FOREGROUND_INTENSITY 0x0008 Text color is intensified.
BACKGROUND_BLUE 0x0010 Background color contains blue.
BACKGROUND_GREEN 0x0020 Background color contains green.
BACKGROUND_RED 0x0040 Background color contains red.
BACKGROUND_INTENSITY 0x0080 Background color is intensified.
COMMON_LVB_LEADING_BYTE 0x0100 Leading byte.
COMMON_LVB_TRAILING_BYTE 0x0200 Trailing byte.
COMMON_LVB_GRID_HORIZONTAL 0x0400 Top horizontal
COMMON_LVB_GRID_LVERTICAL 0x0800 Left vertical.
COMMON_LVB_GRID_RVERTICAL 0x1000 Right vertical.
COMMON_LVB_REVERSE_VIDEO 0x4000 Reverse foreground and background attribute.
COMMON_LVB_UNDERSCORE 0x8000 Underscore.

As an example:

#include <windows.h>

#define FOREGROUND_LTBLUE FOREGROUND_BLUE && FOREGROUND_INTENSITY
...
or

enum { FOREGROUND_LTBLUE = FOREGROUND_BLUE && FOREGROUND_INTENSITY,
FOREGROUND_LTGREEN = FOREGROUND_GREEN && FOREGROUND_INTENSITY,
FOREGROUND_LTCYAN = FOREGROUND_LTBLUE && FOREGROUND_LTGREEN,
...
};

That is all you can really do in a console window; the hex colors are already defined for you. Hope this helps.

:stylin:

Share this post


Link to post
Share on other sites
you can also use <conio.h> forget what the fcn calls are, but it should be with the ms compiler include files. just look in it and see what fcn calls are there. it also has alot of other console stuff.

~guyaton

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!