home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap15 / modeinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-07  |  2.7 KB  |  87 lines

  1. /* modeinfo.c -- set modes and obtain information      */
  2. /* Demonstrates _setvideomode() and _getvideoconfig()  */
  3. /* If you load graphics.qlb, no program list is needed.*/
  4.  
  5. #include <conio.h>
  6. #include <graph.h>
  7. struct videoconfig vc;
  8. int modes[15] ={_TEXTBW40, _TEXTC40, _TEXTBW80, _TEXTC80,
  9.         _MRES4COLOR, _MRESNOCOLOR, _HRESBW, _TEXTMONO,
  10.         _MRES16COLOR, _HRES16COLOR, _ERESNOCOLOR, _ERESCOLOR,
  11.         _VRES2COLOR, _VRES16COLOR, _MRES256COLOR};
  12. char *Adapt(short), *Display(short);
  13. main()
  14. {
  15.     int i;
  16.  
  17.     for (i = 0; i < 15; i++)
  18.     {
  19.         if (_setvideomode(modes[i]))
  20.         {
  21.             _getvideoconfig(&vc);
  22.             printf("video mode is %d\n", vc.mode);
  23.             printf("number of columns is %d\n", vc.numtextcols);
  24.             printf("number of colors is %d\n", vc.numcolors);
  25.             printf("number of pages is %d\n", vc.numvideopages);
  26.             printf("adapter is %s\n", Adapt(vc.adapter));
  27.             printf("display is %s\n", Display(vc.monitor));
  28.             printf("the adapter has %dK of memory\n",
  29.                     vc.memory);
  30.         }
  31.         else
  32.             printf("mode %d not supported\n", modes[i]);
  33.         printf("strike a key for next mode\n");
  34.         getch();
  35.     }
  36.     _setvideomode (_DEFAULTMODE);
  37. }
  38.  
  39. /* Adapt() returns a pointer to a string describing   */
  40. /* the adapter characterized by adapt_num.            */
  41. char *Adapt(adapt_num)
  42. short adapt_num; /* videoconfig.adapter value         */
  43. {
  44.     static char *anames[6] = {"Monochrome", "CGA", "EGA",
  45.                               "MCGA", "VGA", "Not known"};
  46.     char *point;
  47.  
  48.     switch (adapt_num)
  49.     {
  50.         case _MDPA : point = anames[0];
  51.                      break;
  52.         case _CGA  : point = anames[1];
  53.                      break;
  54.         case _EGA  : point = anames[2];
  55.                      break;
  56.         case _MCGA : point = anames[3];
  57.                      break;
  58.         case _VGA  : point = anames[4];
  59.                      break;
  60.         default    : point = anames[5];
  61.     }
  62.     return point;
  63. }
  64.  
  65. /* Display() returns a pointer to a string describing  */
  66. /* the monitor characterized by disp.                  */
  67. char *Display(disp)
  68. short disp;  /* videoconfig.monitor value              */
  69. {
  70.     static char *types[5] = {"monochrome", "color",
  71.                              "enhanced color", "analog",
  72.                              "unknown"};
  73.     char *point;
  74.  
  75.     if (disp & _MONO)
  76.         point = types[0];
  77.     else if (disp & _COLOR)
  78.         point = types[1];
  79.     else if (disp & _ENHCOLOR)
  80.         point = types[2];
  81.     else if (disp & _ANALOG)
  82.         point = types[3];
  83.     else
  84.         point = types[4];
  85.     return point;
  86. }
  87.