Thread: console background

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    9

    console background

    Hello
    Can any one the code required to
    change the console background color
    or the color of user screen

    Thank you
    Kishore

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

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    A second way would be

    Code:
    DrawColorString("",0,5,FOREGROUND_RED | FOREGROUND_GREEN);
    using this function:

    Code:
    void DrawColorString(string szText, int X, int Y, WORD color)
    {	
       HANDLE OutputH;										
    	COORD position = {X, Y};							
    	OutputH = GetStdHandle(STD_OUTPUT_HANDLE);			
    	SetConsoleTextAttribute(OutputH, color);			
    	SetConsoleCursorPosition(OutputH, position);		
    	cout << szText;

  4. #4
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Its in the FAQ. Just change (I'm assuming your using windows) this:
    Code:
     SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_INTENSITY );
    To this:
    Code:
    SetConsoleTextAttribute ( h, BACKGROUND_RED | BACKGROUND_INTENSITY );
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Run in background - No console
    By Govalant in forum C Programming
    Replies: 6
    Last Post: 08-05-2007, 04:07 PM
  2. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 09:59 PM
  3. how to change background color in console mode
    By smore in forum C++ Programming
    Replies: 1
    Last Post: 12-02-2003, 01:44 PM
  4. Console in Background
    By Unregistered in forum C++ Programming
    Replies: 6
    Last Post: 04-23-2002, 05:13 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM