鼠标问题,哪里错了呢?
#include "C:\borlandc\save\h\all.H"#include "C:\borlandc\save\h\mouse.H"
int initmouse(int xmi,int xma,int ymi,int yma) //鼠标器初始函数
{
int retcode;
union REGS regs;
regs.x.ax=0;
int86(51,®s,®s);
retcode=regs.x.ax;
if(retcode==0)
{
printf("NOT INSTALL MOUSE BGI !!! "); //返回0值表示鼠标或鼠标驱动程序未安装
return 0;
}
regs.x.ax=7;
regs.x.cx=xmi;
regs.x.dx=xma;
int86(51,®s,®s);
regs.x.ax=8;
regs.x.cx=ymi;
regs.x.dx=yma;
int86(51,®s,®s); //表示鼠标器和驱动程序已安装
return retcode;
}
int read(int *mx, int *my, int *mbutt) //获得鼠标的当前位置
{
int xx0 = *mx;
int yy0 = *my;
int but0 = 0, mb, xnew, ynew;
do
{
union REGS regs ;
regs.x.ax = 3;
int86(51, ®s, ®s);
xnew = regs.x.cx;
ynew = regs.x.dx;
*mbutt = regs.x.bx;
}while (xnew==xx0&&ynew==yy0&&*mbutt==but0);
*mx = xnew;
*my = ynew;
return 0 ;
}
void newmouse(int *mx, int *my, int *mbutt) //把前一位置的鼠标除去,画当前位置的新鼠标
{
int x0=*mx,y0=*my,x,y,xm,ym;
read(&xm, &ym, *mbutt);
drawmouse(x0,y0);
drawmouse(xm,ym);
*mx = xm; //将鼠标的当前位置作为下一新鼠标的前一位置
*my = ym;
}
void drawmouse(int x,int y) // 画出鼠标
{
setwritemode(XOR_PUT);//异或
setlinestyle(0,0,1);
setcolor(RED);
line(x,y,x+11,y+11);
line(x+10,y+11,x+8,y+11);
line(x+7,y+11,x+10,y+19);
line(x+9,y+20,x+8,y+20);
line(x+7,y+19,x+4,y+12);
line(x+3,y+13,x+1,y+15);
line(x,y+16,x,y+1);
setcolor(DARKGRAY);
line(x+1,y+2,x+1,y+14);
line(x+2,y+3,x+2,y+13);
line(x+3,y+4,x+3,y+12);
line(x+4,y+5,x+4,y+11);
line(x+5,y+6,x+5,y+13);
line(x+6,y+7,x+6,y+15);
line(x+7,y+8,x+7,y+10);
line(x+7,y+14,x+7,y+17);
line(x+8,y+9,x+8,y+10);
line(x+8,y+16,x+8,y+19);
line(x+9,y+10,x+9,y+10);
line(x+9,y+18,x+9,y+19);
setwritemode(COPY_PUT);//复制
}
头文件换一下就行了
求正确答案啊