Like Tree4Likes
  • 1 Post By quzah
  • 1 Post By CommonTater
  • 1 Post By rainbow9
  • 1 Post By CommonTater

how to change the background color in text mode in C?

This is a discussion on how to change the background color in text mode in C? within the C Programming forums, part of the General Programming Boards category; Hi. How to change the background color in text mode in C? Things I have tried: textbackgroundcolor(BLUE); I know how ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    16

    how to change the background color in text mode in C?

    Hi. How to change the background color in text mode in C?

    Things I have tried:

    textbackgroundcolor(BLUE);

    I know how to change color of text. But I don't have a clue about the background.
    Here it is for the text:
    Cprogramming.com FAQ > Color my text

    I also do know how to do it partially, just bellow the text. This is here:
    Win32 Console Applications 4

    I would like to do it everywhere, not just bellow the text.

    Another idea could be the "system("cls")" command, but it always clears it to black color.

    Also, if it is necessary I am using Windows 64 bits, Dev compiler.

    Thank you.

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Actually, with the console mode that you are using the only way is to print a blank character with the backgroundtextcolor set to the desired color for your "background". Since this is obviously not what you want to do, you are going to need to get into console graphics programming. Start here and then ask questions if you have them.

    You may also want to look at console functions.
    Last edited by AndrewHunter; 07-14-2011 at 03:41 PM.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Us old dinosaurs used to use: ANSI escape code - Wikipedia, the free encyclopedia


    Quzah.
    AndrewHunter likes this.
    Hope is the first step on the road to disappointment.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Wellllll.... you might try looking up the conio library in your C documentation.

    In it you will find textcolor() and textbackground()... and a whole lot of other helpful things.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    In it you will find textcolor() and textbackground()... and a whole lot of other helpful things.
    That was one nice thing about Borland's Pascal compiler...


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    That was one nice thing about Borland's Pascal compiler...
    Quzah.
    Pelles C supports it too... in both x86 and x64 code.

    And yes I still wish almost every day Borland had not destroyed Pascal with that ultra-splendiferous pile of bloatware crap called Delphi.
    AndrewHunter likes this.

  7. #7
    Banned
    Join Date
    Jul 2011
    Posts
    1
    The Color of a Console window in windows can be changed by using the 'color' command eg-open cmd and type in color 09,you can see the background color has change to black and text color has change to blue.So,refer to Console help to get different color codes.

    You can Implement this in your C program by using the code: 'System("color 09")'.
    <<Don't>> Visit <<a lousy website>> for C programming Examples,tips and source codes.
    Last edited by laserlight; 07-17-2011 at 10:01 AM.
    Farhan Azam likes this.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by rainbow9 View Post
    You can Implement this in your C program by using the code: 'System("color 09")'.
    Ok... now why on earth would someone want to use an external command to do a task that is dead easy to implement internally...
    Code:
    textcolor(09);
    The system() function is NOT a mainstay in C because almost everything you want to do is already implemented in C's standard libraries and 3rd party libraries that are easily downloaded.

    Visit c-madeeasy.blogspot.com for C programming Examples,tips and source codes.
    And we have a winner ladies and gentlemen....
    http://c-madeeasy.blogspot.com/searc...&max-results=3

    Why in the name of all that's holy would you want to use that piece of crap dinosaur age compiler when there are up to date free and standards compliant 32 and 64 bit compilers you can download right now...

    Pelles C ... no dos box, no stupid blue windows, no messing with 16 bit code... fully windows ready, C-99 standard x86 and x64 compilers, full resource editor suite... and it's free...
    Last edited by CommonTater; 07-17-2011 at 09:59 AM.
    AndrewHunter likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. change background color
    By new_in_c++ in forum Windows Programming
    Replies: 1
    Last Post: 07-12-2011, 12:08 PM
  2. Unable to change the windows background color
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 12-29-2007, 01:31 AM
  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. How do I change background color?
    By kinghajj in forum Windows Programming
    Replies: 16
    Last Post: 11-10-2003, 02:20 AM
  5. Can I change background color
    By Bryan in forum C++ Programming
    Replies: 2
    Last Post: 10-25-2002, 01:14 PM

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