Strange thing happens...

This is a discussion on Strange thing happens... within the C++ Programming forums, part of the General Programming Boards category; It seems like when im dealing with colored text and the text scrolls off the screen it turns gray...then back ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    249

    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;
    
    }

  2. #2
    Registered User mepaco's Avatar
    Join Date
    Aug 2002
    Posts
    47
    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.
    Last edited by mepaco; 09-10-2002 at 01:35 PM.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    249

    Question 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???

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    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
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange struct syntax; type name:number
    By OnionKnight in forum C Programming
    Replies: 1
    Last Post: 11-19-2006, 07:23 PM
  2. strange linking error -- can not find shared library
    By George2 in forum C Programming
    Replies: 2
    Last Post: 07-10-2006, 10:51 PM
  3. "new" is strange
    By The Wazaa in forum C++ Programming
    Replies: 26
    Last Post: 03-06-2006, 11:32 AM
  4. Strange results using dnsapi and windns
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-13-2005, 10:21 AM
  5. Very strange linker error
    By hajohoff in forum C++ Programming
    Replies: 2
    Last Post: 05-13-2005, 07:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21