color

This is a discussion on color within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm using microsoft visual c++ and I was wonderig if anyone knows how to change the color of individual ...

  1. #1
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262

    color

    Hi, I'm using microsoft visual c++ and I was wonderig if anyone knows how to change the color of individual characters in an array .... if anyone can help, great!!!!!

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    Pennsylvania
    Posts
    434
    Yes there is let me see if i can dig out an old program i have around here somewhere...

    Well first off you need to include windows.h in the includes (where else would you put them? lol)

    Well i cant find my files but here is a link...

    http://www.codeproject.com/cpp/cppfo...#cons_txtcolor

  3. #3
    Registered User
    Join Date
    Nov 2004
    Location
    Pennsylvania
    Posts
    434
    After doing some Google searches it has kinda come back to me a little bit. Try this and just mess around with stuff til you figure it out

    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
        //setup some stuff
        HANDLE hConsole;
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
        cout<<"Red\n";
        SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE);
        cout<<"Blue\n";
        SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN);
        cout<<"Green\n";
        SetConsoleTextAttribute(hConsole, 15);
        cout<<"There are a ton of ways to manipulate colors, give em a try!\n\n";
        cin.get();
    }
    You can also try this:

    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
        HANDLE hConsole;
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        for(int i=0; i<255; i++)
        {
            SetConsoleTextAttribute(hConsole, i);
            cout<<"There are a ton of different combinations!!!\n";
        }
        cin.get();
    }
    Have fun!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 07:23 PM
  2. egavga.bgi problem
    By sunil21 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-22-2003, 06:06 PM
  3. My opinion on skin color
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 07-11-2003, 01:12 PM
  4. [WinAPI] Developing a color customizable program
    By Templario in forum Windows Programming
    Replies: 6
    Last Post: 02-04-2003, 06:12 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM

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