/*5-2.c*/
#include
#include
#include
#include
union REGS r;
void mouse(int x,int y)
{
line(x-5,y,x+5,y);
line(x,y-5,x,y+5);
}
void read(int *x,int *y,int *mbutt,int *oldx,int *oldy)
{
*oldx=*x;
*oldy=*y;
do
{r.x.ax=3;
int86(51,&r,&r); /*产生鼠标中断*/
*x=r.x.cx; /*光标当前X坐标*/
*y=r.x.dx; /*光标当前Y坐标*/
*mbutt=r.x.bx; /*按键状态*/
}while(*x==*oldx&&*y==*oldy&&*mbutt==0);
}
main()
{
char *strx,*stry;
int mx,my,ox,oy;
int butt;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\bc\\bin\\bgi");
setwritemode(XOR_PUT);
r.x.ax=3;
int86(51,&r,&r);
mx=r.x.dx;
my=r.x.cx;
butt=r.x.bx;
mouse(mx,my);
setfillstyle(1,BLACK);
for(;;)
{
bar(5,5,100,25);
sprintf(strx,"%d",mx);
sprintf(stry,"%d",my);
outtextxy(10,10,strx);
outtextxy(60,10,stry);
delay(20);
read(&mx,&my,&butt,&ox,&oy);
mouse(ox,oy);
mouse(mx,my);
if(butt==1)
exit(0);
}
}