Thread: color wont change in console

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    20

    color wont change in console

    I'm using Bloodshed's Dev-C++

    Code:
    HANDLE hInput, hOutput;
    
    void FillScreenGreen()
    {
        COORD FillScreenPos;
        for(int i=0; i<25; i++)
        {
            for(int i2=0; i2<80; i2++)
            {
                FillScreenPos.Y=i;
                FillScreenPos.X=i2;
                SetConsoleCursorPosition(hOutput, FillScreenPos);
                SetConsoleTextAttribute(hOutput, BACKGROUND_GREEN | FOREGROUND_GREEN);
                cout<<"x";
            }
        }
        SetConsoleTextAttribute(hOutput, BACKGROUND_GREEN);
    }           
    
    int main()
    {
        hInput = GetStdHandle(STD_INPUT_HANDLE);
        hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
        FillScreenGreen();
    
        return 0;
    }
    The above should fill the whole screen with a green background color, right? But when I run the program it won't change color...

    plz help
    Last edited by Xarr; 06-10-2004 at 02:03 PM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    That code fills an 80x25 grid of characters to solid green - works fine.

    Try adding a "cin.get();" right before you return from main().

    gg

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    20
    It's very odd... My console (cmd - WinXP Pro) wont change color :S

    Is it something about the settings of the console (or the set mode)? or the properties of the program ?

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Worked fine on XP too....

    Using Dev-C++ 4.9.8.0

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with C program
    By ChrisH in forum C Programming
    Replies: 38
    Last Post: 11-13-2004, 01:11 AM
  2. adding a function to a program
    By trippedwire in forum C++ Programming
    Replies: 9
    Last Post: 09-30-2004, 12:35 PM
  3. help with calculating change from a dollar
    By z.tron in forum C++ Programming
    Replies: 3
    Last Post: 09-13-2002, 03:58 PM
  4. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM