SetConsoleTextAttribute() Help!!!

This is a discussion on SetConsoleTextAttribute() Help!!! within the C++ Programming forums, part of the General Programming Boards category; SetConsoleTextAttribute(.....,BACKGROUND_BLUE); can i replace BACKGROUND_BLUE with hex color, such as RGB color? If yes, how to do it? Thank...

  1. #1
    Unregistered
    Guest

    SetConsoleTextAttribute() Help!!!

    SetConsoleTextAttribute(.....,BACKGROUND_BLUE);

    can i replace BACKGROUND_BLUE with hex color, such as RGB color? If yes, how to do it?
    Thank

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    I dont think so.......the 3 colours allowed are defined as so

    #define BACKGROUND_BLUE 0x0010 // background color contains blue.
    #define BACKGROUND_GREEN 0x0020 // background color contains green.
    #define BACKGROUND_RED 0x0040 // background color contains red.
    Theese are then OR'ed....if you want a more diverse coulour system.....so for a full GUI application.

  3. #3
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 2);

    You just change the number to your liking. And to get brighter colors do this:

    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 2 | FOREGROUND_INTENSITY);

    next time go here

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by TechWins
    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 2);

    You just change the number to your liking. And to get brighter colors do this:

    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 2 | FOREGROUND_INTENSITY);

    next time go here
    Yes but that doesnt give the colour diversity that a normal RGB will offer.........

    Sometimes you have to shed the mantles of the console to get what you need......

  5. #5
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Yes but that doesnt give the colour diversity that a normal RGB will offer.........

    Sometimes you have to shed the mantles of the console to get what you need......
    I agree, but for realitive simplicity what I suggested is a good solution.

Popular pages Recent additions subscribe to a feed

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