Mouse Programming

#include
#include
#include
#include
#include
union REGS in,out;

int callmouse()
{
in.x.ax=1;
int86(51,&in,&out);
return 1;
}
void mouseposi(int &xpos,int &ypos,int &click)
{
in.x.ax=3;
int86(51,&in,&out);
click=out.x.bx;
xpos=out.x.cx;
ypos=out.x.dx;

}
int mousehide()
{
in.x.ax=2;
int86(51,&in,&out);
return 1;
}
void setposi(int &xpos,int &ypos)
{
in.x.ax=4;
in.x.cx=xpos;
in.x.dx=ypos;
int86(51,&in,&out);
}
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
in.x.ax=7;
in.x.cx=x1;
in.x.dx=x2;
int86(51,&in,&out);
in.x.ax=8;
in.x.cx=y1;
in.x.dx=y2;
int86(51,&in,&out);
}
int main()
{
int x,y,cl,a,b;
clrscr();
int g=DETECT,m;
initgraph(&g,&m,'c: cgi');
a=100;
b=300;
setposi(a,b);
restrictmouseptr(0,0,600,400);
callmouse();
while(!kbhit())
{ mouseposi(x,y,cl);gotoxy(1,1);cout< getch();
}

Mouse Functions

callmouse()

mouseposi(x,y,c)


mousehide()

setposi(a,b)

restrictmouseptr(x1,y1,x2,y2)
Calls default mouse pointer on screen

Returns mouse positions to memory location 'x' & 'y' and 1or 2 for clicks to 'c'

Hides default Mouse pointer

Sets the mouse position to 'a' and 'b'

Creates an area (reactangle) where mouse can move
c++ source codes