-
Strange thing happens...
It seems like when im dealing with colored text and the text scrolls off the screen it turns gray...then back to the colored text again...Check this out:
Code:
#include <iostream.h>
#include <conio.h>
#include <windows.h>
char x;
HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
int main (void)
{
SetConsoleTextAttribute(stdOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
system("CLS");
cout<<"This is white text\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout<<endl;
getch();
cout<<"This is should be white text";
cout<<endl<<endl<<endl<<endl;
getch();
cout<<"This should be white text";
cout<<"\nThis is white text ";
return 0;
}
-
Well, I ran your code and all I got was white text on a black background. Nothing else.
Edit: I'm running Windows2K and also running MSVC6.
-
Hmm..
Well, I'm running Windows Me and MSVC6 compiler. When i run this, the part that says "this should be white text" is gray. I dont understand???:confused:
-
funky,
Code:
#include <iostream.h>
#include <conio.h>
#include <windows.h>
//char x;
HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
int main (void)
{
SetConsoleTextAttribute(stdOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
system("CLS");
cout<<"#1: This is white text\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
//cout<endl;
cout<<flush;
getch();
cout<<"#2: This is should be white text";
//cout<<endl<<endl<<endl<<endl;
cout<<flush;
getch();
cout<<"\n#3 :This should be white text";
cout<<"\n#4: This is white text \n";
return 0;
}
I don't understand, either. (I'm not a "windows" programmer.) This code works, as I understand the way that you want it to work. The problem lies in your escape characters (and 'endl').
Using "system("CLS");" works, as well, but formatting is shot in the back-side, if you get my meaning. :)
You're going to need someone sharper on this stuff than I am to answer your questions as to the "why" and "wherefore".
-Skipper