#include<graphics.h>
#include<conio.h>
#include<dos.h>
void ui();
int condition();
void showmouseptr();
void getmousepos();
union REGS i, o;
void main()
{
int gd = DETECT, gm, status, button, x, y,i,j,col=1;
char array[50];
initgraph(&gd,&gm,"C:\\TC\\BGI");
status = initmouse();
if ( status == 0 )
printf("Mouse support not available.\n");
else
{
gotoxy(77,25);
printf("E");
for(j=0;j<=417;j++)
{
setcolor(WHITE);
rectangle(10,47+j,2+j+170,47);
}
ui();
showmouseptr();
getmousepos(&button,&x,&y);
while(!kbhit())
{
getmousepos(&button,&x,&y);
col=condition(x,y);
if( button == 1 )
{
if((((x>600)&&(x<635))&&((y>1)&&(y<35))))
exit(1);
else if(((y>50)&&(x<635))&&((x>20)))
{
if(col==1)
setcolor(RED);
else if(col==2)
setcolor(YELLOW);
else if(col==3)
setcolor(GREEN);
else if(col==4)
setcolor(BLUE);
else if(col==5)
setcolor(WHITE);
else if(col==6)
setcolor(CYAN);
for(i=0;i<=10;i++)
{
circle(x,y,i);
}
button = -1;
}
}
}
}
getch();
}
int initmouse()
{
i.x.ax = 0;
int86(0X33,&i,&o);
return ( o.x.ax );
}
void showmouseptr()
{
i.x.ax = 1;
int86(0X33,&i,&o);
}
void getmousepos(int *button, int *x, int *y)
{
i.x.ax = 3;
int86(0X33,&i,&o);
*button = o.x.bx;
*x = o.x.cx;
*y = o.x.dx;
}
void ui()
{
int j;
rectangle(1,1,637,35);
gotoxy(35,2);printf("MJ Paint");
rectangle(600,1,637,35);
gotoxy(78,2);printf("X");
rectangle(600,45,635,260);
setcolor(RED);
rectangle(605,50,630,80);
setcolor(YELLOW);
rectangle(605,85,630,115);
setcolor(GREEN);
rectangle(605,120,630,150);
setcolor(BLUE);
rectangle(605,155,630,185);
setcolor(WHITE);
rectangle(605,190,630,220);
setcolor(CYAN);
rectangle(605,225,630,255);
setcolor(WHITE);
rectangle(600,380,630,400);
}
int condition(int x,int y)
{
int clr;
if(((x>605)&&(y>50))&&((x<630)&&(y<80)))
{
clr=1;
}
if(((x>605)&&(y>85))&&((x<630)&&(y<115)))
{
clr=2;
}
if(((x>605)&&(y>120))&&((x<630)&&(y<150)))
{
clr=3;
}
if(((x>605)&&(y>155))&&((x<630)&&(y<185)))
{
clr=4;
}
if(((x>605)&&(y>190))&&((x<630)&&(y<225)))
{
clr=5;
}
if(((x>605)&&(y>225))&&((x<630)&&(y<255)))
{
clr=6;
}
if(((x>605)&&(y>380))&&((x<630)&&(y<400)))
{
clr=5;
}
return(clr);
}