Ok, having some serious trouble here. My proffesor told us to write a progrm (what it does really doesnt matter here) however he wants a FULL color menu in the console. He showed us an example of what he wants, it was very cool, it had a red backround, then a giant blue box in the forground with all the menu selections and he even incorparated the little shadown on the bottom right side (looked like a typical dos program menu) He wrote his in assembly language (we dont know that yet) but he said that you can use system(); function with the 'color' command to do the same thing. However, when researching this online, people were saying that it is impossible using color command because you can only change the backround and foreground of the ENTIRE field, not certain areas..... is this true???

system( ) calls will probably not do what you want.

To some degree, you can fullfill the task using console commands, like
SetConsoleTextAttribute( )

See more here

It's not a trivial problem.

Although Possible ( Might not be what your teacher intended ) you could also try to GDI functions such as Rectangle(), LineTo(), and TextOut().

Your professor is a jerk. (Anyone who would instruct his students to do something before doing it himself the same way students would is a jerk.) Using system( "color 1B" ); doesn't work -- that modifies the color of the entire console window.

Since you are on Windows, there are two (good) options to you. The first is to use the Win32 SetConsoleTextAttribute() function like vmanes instructed you. You can set both foreground and background colors with it.

Here is an example program:

#include <iostream>
#include <limits>
using namespace std;

#include <windows.h>

int main()
  {
  HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
  WORD color;
  CONSOLE_SCREEN_BUFFER_INFO csbi;

  GetConsoleScreenBufferInfo( hStdOut, &csbi );

  for (unsigned f = 0; f < 16; f++)
    {
    for (unsigned b = 0; b < 16; b++)
      {
      // On Windows, the color is just this: very easy to calculate.
      color = (b << 4) + f;
      SetConsoleTextAttribute( hStdOut, color );
      cout << " A ";
      }
    SetConsoleTextAttribute( hStdOut, csbi.wAttributes );
    cout << endl;
    }

  cout << "Press ENTER to quit..." << flush;
  cin.ignore( numeric_limits <streamsize> ::max(), '\n' );

  return 0;
  }

(Clearing the screen is another trick. See here or here for more.)


The other option is to use the Curses library, which is a portable terminal handling library. For Windows versions, check out PDCurses.

Here is a sample program that uses it:

#include <curses.h>

int main()
  {
  int f, b, color_index;

  initscr();
  start_color();

  for (f = 0; f < 16; f++)
    {
    for (b = 0; b < 16; b++)
      {
      // Curses makes setting colors a bit more difficult.
      // You must first have an indexed COLOR PAIR to initialize.
      // High-intensity colors (both foreground and background) are
      // not colors you can choose from. You must get them by
      // adjusting the BOLD and BLINK attributes when using the
      // pair, like so:
      color_index = ((b % 8) * 8) +(f % 8);  // calculate color pair index
      init_pair( color_index, f % 8, b % 8 );  // initialize the pair
      attrset(  // use the pair, applying our desired BOLD and BLINK
        COLOR_PAIR( color_index )
        | ((f < 8) ? 0 : A_BOLD)
        | ((b < 8) ? 0 : A_BLINK)
        );
      printw( " A " );
      }
    attrset( COLOR_PAIR( 0 ) );
    printw( "\n" );
    }

  printw( "There are %d colors and %d pairs available.\nPress ENTER...",
    COLORS,
    COLOR_PAIRS
    );
  refresh();

  getch();
  endwin();
  return 0;
  }

When you compile, be sure to link with the pdcurses lib. For example, using MinGW, I type: g++ a.cpp -lpdcurses Hope this helps.

Well first, thanks for all the replies. Second, Im glad that everyone here has confirmed what my hours of research have told me. I was starting to think I was either being really dumb are that the prof gave us somthing totally wrong. It should be interesting going to class tonight to see what he says. Again, thanks to all!!

This question has already been answered. Start a new discussion instead.