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

Archives

program which draw rectangles on the screen with the help of mouse

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
int a,b,c,k;
void main()
{   clrscr();
    int d,mm,e;
    d=DETECT;
    initgraph(&d,&mm,"c:/tc");
    e=graphresult();
    if(e!=0)
    {  cout<<" graphics r not opened";
       getch();
       return;
    }
    setbkcolor(7);
    REGS n,m;
    n.x.ax=0;
    int86(0x33,&n,&m);
    k=m.x.ax;
    if(k==0)
    return;
    int aa,bb,t1=0,t2=0,p=0,g=0;
    while(!kbhit())
    {  n.x.ax=1;
       int86(0x33,&n,&m);
       n.x.ax=3;
       int86(0x33,&n,&m);
       a=m.x.cx;
       b=m.x.dx;
       c=m.x.bx;

       if(c==1)
       {   g=1;
       if(p==0)
       {  aa=a;
          bb=b;
          p++;
       }
       if(t1!=a||t2!=b)
       {   setcolor(7);
           rectangle(aa,bb,t1,t2);
        //  cleardevice();
       }
       t1=a;
       t2=b;
       setcolor(1);
       rectangle(aa,bb,a,b);

       }
       else
       {   p=0;
       if(g==1)
       {  rectangle(aa,bb,t1,t2);
          g=0;
       }
       }
   }
    getch();
    closegraph();
 }

0 comments: