console text colors??

This is a discussion on console text colors?? within the C++ Programming forums, part of the General Programming Boards category; is there a way to change the text colors in the console...

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

    console text colors??

    is there a way to change the text colors in the console

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    For a windows machine.......look up the SetConsoleTextAttribute() API function on MSDN....

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Lightbulb Like this, maybe?

    textcolor(RED); // For Red
    textcolor(GREEN); // For Green
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    35
    what do I need to include?

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    178
    It depends on what your compiler is, I'm not sure about the others, but in dev-cpp it is <conio.c>

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Just as Fordy stated...simply include windows.h and use this:

    Code:
    SetConsoleTextAttribute( GetStdHandle(
                                             STD_OUTPUT_HANDLE ), 
                                             FOREGROUND_RED );
    Experiment also FOREGROUND_BLUE, FOREGROUND_GREEN.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  2. Console Text RPG- File I/O and Inventory
    By Jontay in forum Game Programming
    Replies: 17
    Last Post: 11-23-2003, 01:37 AM
  3. retreiving console window text
    By mayhem in forum Windows Programming
    Replies: 2
    Last Post: 09-10-2003, 09:40 PM
  4. Console text input
    By Drew53385 in forum C++ Programming
    Replies: 3
    Last Post: 04-18-2003, 10:33 AM
  5. Console Text Scrolling Help!!
    By frgmstr in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2002, 01:37 PM

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