int main() { int x,y,cl,prcl,x1,y1,dx,dy; int g=DETECT,m; initgraph(&g,&m,"..\\bgi"); cleardevice(); setposi(10,10); callmouse(); prcl=0; do { mouseposi(&x,&y,&cl); if(cl==prcl && prcl==1) { x1=x; y1=y; while(cl!=0) { mouseposi(&x,&y,&cl); } dx=x-x1; dy=y-y1; gotoxy(2,2); if(dx==0 && dy==0) { gotoxy(2,2); printf("\n\t Mouse Clicked : %+04d,%+04d",x,y); } else { gotoxy(2,3); printf ("\n\tMouse dragged (DX,DY): %+04d,%+04d",dx,dy); } } gotoxy(2,5); printf("\n\tMouse Position is: %03d,%03d",x,y); prcl=cl; }while(!kbhit()); getch(); return 1; }
int main() { int x,y,cl,a,b; int g=DETECT,m; initgraph(&g,&m,"..\\bgi"); cleardevice(); a=100; b=400; setposi(&a,&b); callmouse(); do { mouseposi(&x,&y,&cl); gotoxy(10,9); printf("\n\tMouse Position is: %d,%d",x,y); printf("\n\tClick: %d",cl); printf("\n\tPress any key to hide the mouse"); }while(!kbhit()); getch(); mousehide(); printf("\n\n\tPress any key to Exit"); getch(); return 1; }
void code() { int x1,y1,cl; int x=28,y=4; int p=28,q=4; int r=28,s=4; int i=28; int j=0; char c; textcolor(0); do { if(y+5>17&&x==i) { gover(); getch(); exit(1); } if(q+5>17&&p==i) { gover(); getch(); exit(1); } if(s+5>17&&r==i) { gover(); getch(); exit(1); } clrscr(); gframe(); if (j>7) { if(q==17) { q=4; p=28+(7*(j%3)); } textcolor(15); object(p,q); q++; } if (j>15) { if(s==17) { s=4; r=28+(7*((j+1)%3)); } textcolor(15); object(r,s); s++; } if(y==17) { y=4; x=28+(7*((j+2)%3)); } textcolor(15); // object(x,y); y++; textcolor(1); gotoxy(i,18); cprintf(" ^ ^ "); gotoxy(i,19); cprintf("||@*@||"); gotoxy(i,20); cprintf("||***||"); gotoxy(i,21); cprintf(" *** "); gotoxy(i,22); cprintf(" *** "); gotoxy(i,23); cprintf("||***||"); gotoxy(i,24); cprintf("||***||"); mouseposi(&x,&y,&cl); if(cl==1&&i>34) i=i-7; if(cl==2&&i<36) i=i+7; j++; delay(300) ; }while(!kbhit()); }