Changing the background colour

This is a discussion on Changing the background colour within the C Programming forums, part of the General Programming Boards category; Is it possible to change the black color background to a different color? If it is possible may sharing how ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    1

    Changing the background colour

    Is it possible to change the black color background to a different color?
    If it is possible may sharing how to do it..

    thanks

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    well....that is very system specific to be honest. There is not one standard way to do it.

    Windows, Mac OS X, and Linux all have shells where you can physically change the background color options by selecting some kind of "preferences" menu (slightly varies depending on the OS).

    But I know that's not what you want to know...you want to know how to do it in your program.

    If you are using Windows/DOS: lots of older compilers came with a non-standard header file called dos.h that you could use to do some DOS specific stuff, including change the background color I believe...but most likely you won't have that file, and so that probably won't work.

    Most likely you will have to use some sort of system() command to be able to do it...but I am not familiar with what the command would actually be....
    My Website

    "Circular logic is good because it is."

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    Code:
    #include <stdio.h>
    
    int main()
    {
        /* Some list of combinations 
         
        0 = Black 
        1 = Blue 
        2 = Green 
        3 = Aqua 
        4 = Red 
        5 = Purple 
        6 = Yellow 
        7 = White 
        8 = Gray
        9 = Light Blue
        A = Light Green
        B = Light Aqua
        C = Light Red
        D = Light Purple
        E = Light Yellow
        F = Bright White */
        
        printf("This is a console color change program\n");
        system("COLOR F2"); /* This will change the bgcolor F - White and textcolor to 2- Green */ 
        
        getchar();
        return 0;
    }
    This code is more specific to DOS . It works fine on DOS 5.1.2600 version

    ssharish2005

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,270
    Quote Originally Posted by ssharish2005 View Post
    This code is more specific to DOS . It works fine on DOS 5.1.2600 version
    Dare I even ask why you're running DOS 5?

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by brewbuck View Post
    Dare I even ask why you're running DOS 5?
    perhaps the unparalleled privilege settings?

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    "DOS 5.1.2600" looks suspiciously liek the version of Windows XP SP2 to me. My Win2K shows "5.0.2195" when I do "ver" in a command prompt. I'm pretty darn sure there wasn't a "5.1.2600" version of MS-DOS (or PC-DOS for that matter).

    --
    Mats

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ASM Background and Text Colour
    By peckitt99 in forum Tech Board
    Replies: 1
    Last Post: 10-25-2006, 11:53 PM
  2. changing colour of the background ...
    By twomers in forum C++ Programming
    Replies: 1
    Last Post: 12-08-2005, 08:53 AM
  3. Tab Control - Setting The Background colour
    By ventolin in forum Windows Programming
    Replies: 1
    Last Post: 01-27-2005, 05:13 PM
  4. Background Colour in Windows API
    By Vicked in forum Windows Programming
    Replies: 2
    Last Post: 04-14-2003, 04:49 AM
  5. how to set the background colour of a static box?
    By Cobras2 in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2002, 05:57 PM

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