My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to select the different background colours

Tuesday, September 1, 2009

#include <graphics.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>

void main()
{
   int bkcolor, midx, midy;
   char bkname[35];
   int d,m,e;
   d=DETECT;
   initgraph(&d,&m,"c:/tc");
   e=graphresult();
   if(e!=0)
   { // cout<<" graphics r not opened";
      getch();
      return;
   }
   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   setcolor(getmaxcolor());

/* for centering text on the display */
   settextjustify(CENTER_TEXT, CENTER_TEXT);

/* get the current background color */
   bkcolor = getbkcolor();

/* convert color value into a string */
   itoa(bkcolor, bkname, 10);
   strcat(bkname, " is the current background color.");

/* display a message */
   outtextxy(midx, midy, bkname);

/* clean up */
   getch();
   closegraph();

}

0 comments: