home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol10n13.zip / GETMAXX.C < prev    next >
Text File  |  1991-04-04  |  2KB  |  59 lines

  1. // getmaxx.c RHS 3/4/91
  2.  
  3. #include<graphics.h>
  4. #include<stdlib.h>
  5. #include<stdio.h>
  6. #include<conio.h>
  7.  
  8. #define MAXDRIVERS    3
  9. int graphdrivers[MAXDRIVERS] = { CGA, EGA, VGA };
  10. char *graphdrivernames[MAXDRIVERS] = { "CGA", "EGA", "VGA" };
  11.  
  12. void main(void)
  13.     {
  14.     int graphmode = 0, i, j, low, high, err;
  15.     int midx, midy, texth;
  16.     char xrange[80], yrange[80], drivername[80];
  17.  
  18.  
  19.     for(i = 0; i < MAXDRIVERS; i++)
  20.         {
  21.         initgraph(&graphdrivers[i], &graphmode, "");
  22.  
  23.         if(err = graphresult())
  24.             {
  25.             printf("Graphics error: %s\n",grapherrormsg(err));
  26.             printf("Press any key to exit program...");
  27.             getch();
  28.             restorecrtmode();
  29.             exit(1);
  30.             }
  31.  
  32.         getmoderange(graphdrivers[i],&low,&high);
  33.  
  34.         for( j = 0; j < 2; low = high, j++)
  35.             {
  36.             setgraphmode(low);
  37.             midx = getmaxx() / 2;
  38.             midy = getmaxy() / 2;
  39.  
  40.             sprintf(drivername,"%s, mode:%s number:%d",
  41.                 graphdrivernames[i],
  42.                 getmodename(getgraphmode()),
  43.                 getgraphmode());
  44.             sprintf(xrange,"X values range from 0 to %d",getmaxx());
  45.             sprintf(yrange,"Y values range from 0 to %d",getmaxy());
  46.  
  47.             settextjustify(CENTER_TEXT,CENTER_TEXT);
  48.             texth = textheight("W");
  49.             outtextxy(midx,midy,drivername);
  50.             outtextxy(midx,(midy += texth),xrange);
  51.             outtextxy(midx,(midy += texth),yrange);
  52.             getch();
  53.             }
  54.  
  55.         closegraph();
  56.         }
  57.     exit(0);
  58.     }
  59.