Link to home
Start Free TrialLog in
Avatar of AverageJoez
AverageJoez

asked on

Change color

How do I change the color of the text/background in a C++ console app? Also, how do I make the characters fade in/out?

Thanks.
Avatar of EarthQuaker
EarthQuaker

Avatar of AverageJoez

ASKER

That might work, but I'm looking for a way to change the color in a console app. This link points to a Win32 GUI program.
ASKER CERTIFIED SOLUTION
Avatar of EarthQuaker
EarthQuaker

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To change the color on *nix it's another way, ask if you want to know under *nix.
The prog that was given in the question (https://www.experts-exchange.com/questions/20182590/Console-Programming-System-Color-Command.html) was a C++ Win32 GUI app.

The app that you gave seems to work for the console, but to only make a segment of the output windows a certain color do I do SetConsoleTextAttribute and set the default parameters (black and whit), or is there a way to cancel the function?

Also, do you know how to make characters fade in/out?

Thanks.
It was a Win32 GUI app, what I meant was that it has the solution for your problem in it, I only had to read the link pasted to create the sample I gaved you.

To reput in white over black call that :

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE );

As far as I know, there is no way of fading characters in console... you can maybe trick around like :

while (1)
{
     system ("cls");
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
     cout << "Hello World" << endl;
     Sleep(100);
     system ("cls");
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_INTENSITY);
     cout << "Hello World" << endl;
     Sleep(100);
}