You can mix as many as you like, enjoy.Code:SetConsoleTextAttribute(hStdout, FOREGROUND_RED | BACKGROUND_BLUE);
Printable View
You can mix as many as you like, enjoy.Code:SetConsoleTextAttribute(hStdout, FOREGROUND_RED | BACKGROUND_BLUE);
ahhh....thank you
Ok, I just checked MSDN, and it says that SetConsoleTextAttribute only effects text printed after the call. "This function affects only text written after the function call." But this isn't true (or I'm just really confused.) The function will color all of the text on the screen, no matter when it was printed. What I'm trying to do is to color the headings and credits of my game, but not all of the rest of the text. But I can only get one color on the screen at a time. Here's the code I'm using:
If I take out the second SetConsoleTextAttribute, then the menu is yellow, too, which looks bad. Basically, what I think is happening, is that the console colors all of text the color of the last call, even the text printed before. How can I make it so that it only colors some text? Thank you, and sorry for my ignorance.Code:// set the colors
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY); // yellow
// welcome the user
cout << "Welcome to my adventure game\n";
cout << "written by Jacob Sheehy\n\n";
SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY); // white
// show the user a menu
cout << "Please make a choice.\n";
cout << "1. Create a Character/New Game\n";
cout << "2. Load a Character/Game\n";
cout << "3. Quit\n>";
I just realized I have to use printf() rather than cout.....thanks a bunch guys... :) No really, thanks
.. my sleep goes to begining even if its at the middle?
Well, it depends on how you lie on your bed at night... :) huh? what sleep?
> I just realized I have to use printf() rather than cout.....
That's C programming, not C++.
Try searching google for such a common question.
Try http://www.ProgrammersHeaven.com also.
I believe they had a few tutorials or source code downloads.
I messed around with one the other night..