-
Color changing
Ok I looked around the site and searched a few things on google. I couldnt figure out how to change the color of the text that displays on the screen of a program. Im currently working on the main menu potion of a game, and I want to change some of the text color so its easier to read.
Like when someone presses an incorrect key, text appears saying that it was incorrect and they need to enter another key. I would like that to be red or something, so it sticks out a bit more. I gave it pretty good spacing, but some people might not see it and just think the program is repeating itself for no reason.
If anyoen could explain here how to do this, or give me a link to smowhere that can..it would be much appreciated. Thank you.
-
That's OS specific. Assuming windows:
http://www.adrianxw.dk/SoftwareSite/...Consoles4.html
In Linux your best bet would be ncurses.
-
Ah, hey thanks man. That helps qutie a bit. I aprreciate that!
-
Oooo...um I ran into a snag with that. Ok, I added the color coding to my program. Then I pressed the wrong key perpusly to test it. I have it set so that when a wrong key is pressed the error message shows up, and then it shows the options agian. With the color code in there, when the wrong key is pressed the error message and the repeated options are red. How do I get it to not show the options as being red? Here is the code just incase you need it(also I didnt add in the return 0; because that just closes the program)
Code:
{
SetConsoleTextAttribute(hOut,
FOREGROUND_RED |
FOREGROUND_INTENSITY);
cout << "Sorry, that is not a proper selection. Please choose again.\n\n\n\n" << endl;
}
I dont know if that'l help, but jsut incase it does, its there. Also all the text that appears after that shows up red.
-
Yes, that's because you're changing the colors permenantly. All further output will be in that color, therefor, after you're done outputting the error message, you have to change the color back to normal.
-
lol I guess I didnt really think of that. I got it now, thanks man.