home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / vidhandl / palette.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-03  |  1.6 KB  |  59 lines

  1. /* PALETTE - DISPLAYS THE COLOR SET AVAILABLE FOR TEXT MODE TEXTS */
  2. /*   ALSO AN EXAMPLE OF VIDEO HANDLING FUNCTIONS                  */
  3.  
  4. #include <crt.h>
  5.  
  6. #define CGA  1
  7. #define MCGA 2
  8. #define EGA  3
  9. #define VGA  9
  10.  
  11. #define VIDEO_ADAPTER VGA
  12.   //If your video adapter isn't VGA, redefine VIDEO_ADAPTER with one of
  13.   //above adapter types.
  14.  
  15. void main ()
  16.  {
  17.     int c0,c1; //counters
  18.     char s[5]; //A string that stores the text that is written with each color
  19.  
  20.     s[0]=' '; //Initializes string s.
  21.     s[3]=' '; //s[1] and s[2] are loaded with values during conversion
  22.     s[4]=0; //Null terminating character
  23.  
  24.     crt_detect(VIDEO_ADAPTER); //Gets current video status (it is, number of rows, columns, etc)
  25.  
  26.     fillscr (' ',0x07); //Clears the screen
  27.  
  28.   //Displays title
  29.     prints ("* * * CURRENT TEXT COLORS * * *",25,1,0x1f);
  30.     prints ("COLOR INDEX (hexadecimal):",5,3,0x0f);
  31.  
  32.   //Displays each color with it's value in hexadecimal notation
  33.     for (c0=0;c0<16;c0++) //c0==background color
  34.      {
  35.         //Converts background color to s[1]
  36.         if (c0<10)
  37.             s[1]=c0+0x30;
  38.          else
  39.             s[1]=c0+0x37;
  40.  
  41.         for (c1=0;c1<16;c1++) //c1==foreground color
  42.          {
  43.             //Converts foreground color to s[2]
  44.             if (c1<10)
  45.                 s[2]=c1+0x30;
  46.             else
  47.                 s[2]=c1+0x37;
  48.             prints (s,4*c0+5,c1+5,c0*16u+(unsigned)c1); //outputs s
  49.          }
  50.      }
  51.  
  52.   //repositions the cursor at the begin of the immediate line that follows the
  53.   //lowermost written line.
  54.     crt_gotoxy (0,21);
  55.  }
  56.  
  57. // By Marcio Afonso Arimura Fialho
  58. // http://pessoal.iconet.com.br/jlfialho
  59. // e-mail: jlfialho@iconet.com.br or (alternate) jlfialho@yahoo.com