How To Change Text Color In A Console Window In Visual C++?

Sharky Forums


Results 1 to 4 of 4

Thread: How To Change Text Color In A Console Window In Visual C++?

  1. #1
    Goldfish
    Join Date
    Jul 2001
    Location
    England
    Posts
    67

    Question How To Change Text Color In A Console Window In Visual C++?

    please can anyone help me... I am in my first year at uni, and i am writing a small text menu based program in visual C++. I just want to know how would i go about changing text color in the console window from white to something else.

    Like i said i am really new to C++ so i would be greatful if you could lay it out a little clearly for me.

    Thanks,

  2. #2
    Tiger Shark
    Join Date
    Feb 2001
    Location
    Satan Country
    Posts
    564
    #include windows.h

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);

    replace 3 with the number of the color.
    I'm half Scottish and half French.

    I surrender to alcohol.

  3. #3
    Catfish df's Avatar
    Join Date
    Sep 2000
    Location
    Lexington VA(USA) + Melbourne(Aus)
    Posts
    146
    use a library like PDCurses if your doing lot of console IO + colour etc.

    then it can be interchanged on unix box with NCurses.

    PDCurses + NCurses are very good!

    my roguelike on win32 uses PDCurses and NCurses on freebsd+linux.
    works a treat.

  4. #4
    Reef Shark biosx's Avatar
    Join Date
    Jun 2001
    Location
    Chicago, IL, USA
    Posts
    448
    Originally posted by df
    use a library like PDCurses if your doing lot of console IO + colour etc.
    Where can you pick up these libraries?


    EDIT: Found them at SourceForge, thanks
    Last edited by biosx; 05-02-2002 at 11:18 AM.
    ## root is the greed of all evil ##

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •