关于Borland C的鼠标问题
程序代码:#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<mouse.c>
#define PIXEL_COUNT 1000
int main(void)
{
int gdriver=DETECT,gmode,errorcode;
int i,x,y,color,maxx,maxy,maxcolor,seed;
int m,n,sta;
cleardevice;
initgraph(&gdriver,&gmode,"c:\\borlandc\\bgi");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("graphics error:%s\n",grapherrormsg(errorcode));
printf("press any key to halt:");
getch();
exit(1);
}
maxx=getmaxx()+1;
maxy=getmaxy()+1;
maxcolor=getmaxcolor()+1;
setcolor(YELLOW);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(maxx/2,400,"Welcome to Smart Home");
while(!kbhit())
{
seed=random(32767);
srand(seed);
for(i=0;i<PIXEL_COUNT;i++)
{
x=random(maxx);
y=random(maxy);
color=random(maxcolor);
putpixel(x,y,color);
}
delay(250);
srand(seed);
for(i=0;i<PIXEL_COUNT;i++)
{
x=random(maxx);
y=random(maxy);
color=random(maxcolor);
if(color==getpixel(x,y))
putpixel(x,y,0);
}
}
getch();
cleardevice;
initmouse();
showcur();
setbkcolor(LIGHTCYAN);
setfillstyle(1,GREEN);
bar(350,80,500,200);
bar(100,80,250,200);
settextstyle(3,HORIZ_DIR,3);
settextjustify(LEFT_TEXT,0);
outtextxy(362,140,"Refrigerator");
settextjustify(LEFT_TEXT,0);
outtextxy(108,140,"Air-condition");
while(1)
{
status(&m,&n,&sta);
if(sta&1&&m>350&&m<500&&n>80&&n<200)
{
hidecur();
exit(1);
}
}
getch();
closegraph();
return 0;
}
这段我用了鼠标代码,每次进入第二个界面,点击第二个图块后,退出,再进就碰到这个图块自动退出了,就像是鼠标左键卡壳了一样0 0.






