#include<stdio.h>
#include<graphics.h>
#include<dos.h>
union REGS i,o;
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
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 main()
{
int gd=DETECT,gm,x,y,maxx=630,maxy=451,button;
initgraph(&gd,&gm,"c:\\tc\\bgi");
rectangle(0,90,maxx,maxy);
setviewport(1,91,maxx-1,maxy-1,1);
gotoxy(33,1);
printf("Mouse Events");
i.x.ax=0;
int86(0x33,&i,&o);
if(o.x.ax==0)
{
restorecrtmode();
printf("Mouse Driver is not loaded.");
}
restrictmouseptr(1,91,maxx,maxy-1);
i.x.ax=1;
int86(0x33,&i,&o);
gotoxy(1,3);
printf("Left Button ");
gotoxy(25,3);
printf("Rigth Button ");
gotoxy(50,5);
printf("press any key to exit.........");
while(!kbhit())
{
getmousepos(&button,&x,&y);
gotoxy(1,5);
if((button&1)==1)
printf("Key is Pressed ");
else
printf("Key is Released ");
gotoxy(25,5);
if ((button&2)==2)
printf("Key is Pressed ");
else
printf("Key is Released ");
gotoxy(65,3);
printf("x= %d y= %d ",x,y);
}
}
#include<graphics.h>
#include<dos.h>
union REGS i,o;
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
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 main()
{
int gd=DETECT,gm,x,y,maxx=630,maxy=451,button;
initgraph(&gd,&gm,"c:\\tc\\bgi");
rectangle(0,90,maxx,maxy);
setviewport(1,91,maxx-1,maxy-1,1);
gotoxy(33,1);
printf("Mouse Events");
i.x.ax=0;
int86(0x33,&i,&o);
if(o.x.ax==0)
{
restorecrtmode();
printf("Mouse Driver is not loaded.");
}
restrictmouseptr(1,91,maxx,maxy-1);
i.x.ax=1;
int86(0x33,&i,&o);
gotoxy(1,3);
printf("Left Button ");
gotoxy(25,3);
printf("Rigth Button ");
gotoxy(50,5);
printf("press any key to exit.........");
while(!kbhit())
{
getmousepos(&button,&x,&y);
gotoxy(1,5);
if((button&1)==1)
printf("Key is Pressed ");
else
printf("Key is Released ");
gotoxy(25,5);
if ((button&2)==2)
printf("Key is Pressed ");
else
printf("Key is Released ");
gotoxy(65,3);
printf("x= %d y= %d ",x,y);
}
}
0 comments:
Post a Comment