static text color/background color

This is a discussion on static text color/background color within the C++ Programming forums, part of the General Programming Boards category; I was wondering if anyone knows how to change the color/background color of static text. Any help, or examples would ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    1

    static text color/background color

    I was wondering if anyone knows how to change the color/background color of static text. Any help, or examples would be appreciated. Thanks!!

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    17
    If you're using a windows compiler simply use

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), c);

    where c is the color.

    there are 16 possible colors for the foreground and other possibilites for the background.

    Foreground

    BLACK
    BLUE
    GREEN
    CYAN
    RED
    MAGENTA
    BROWN
    LIGHTGRAY
    DARKGRAY
    LIGHTBLUE
    LIGHTGREEN
    LIGHTCYAN
    LIGHTRED
    LIGHTMAGENTA
    YELLOW
    WHITE

    Background colors can be intensified, brigtened to make lighter shades out of the colors for example, BACKGROUND_BLUE, can be made lightblue by BACKGROUND_BLUE | BACKGROUND_INTENSITY
    remember, you cannot declare the following colors as backgrounds

    LIGHTGRAY,DARKGRAY,LIGHTBLUE,LIGHTGREEN,LIGHTCYAN, LIGHTRED,LIGHTMAGENTA,YELLOW,WHITE,CYAN,MAGENTA,BR OWN,BLACK

    However you can make most of the colors with the right combinations the exceptions DARKGRAY and BLACK.

    Here are the combinations for the colors

    WHITE-BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY

    LIGHTGRAY-BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE

    LIGHTBLUE-BACKGROUND_BLUE | BACKGROUND_INTENSITY

    LIGHTRED-BACKGROUND_RED | BACKGROUND_INTENSITY

    LIGHTCYAN-BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY

    LIGHTRED-BACKGROUND_RED | BACKGROUND_INTENSITY

    LIGHTMAGENTA-BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY

    YELLOW-BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY

    BROWN -BACKGROUND_RED | BACKGROUND_GREEN

    MAGENTA-BACKGROUND_BLUE | BACKGROUND_RED

    CYAN-BACKGROUND_BLUE | BACKGROUND_GREEN

    This is only the EGA textmode, remember if you are using windows based compilers you are confined to EGA textmode.
    Last edited by Eric08; 07-06-2003 at 06:06 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 01:59 PM
  2. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 02:17 PM
  3. Changing static control text color
    By maxorator in forum Windows Programming
    Replies: 6
    Last Post: 11-03-2005, 09:03 AM
  4. glut text rendering in wrong color
    By ichijoji in forum Game Programming
    Replies: 1
    Last Post: 10-31-2005, 09:02 PM
  5. Reset static control's text ?
    By willc0de4food in forum Windows Programming
    Replies: 12
    Last Post: 08-18-2005, 02:00 AM

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