| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 338 人关注过本帖
标题:我也发一个c语言实现 鼠标的功能
只看楼主 加入收藏
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
结帖率:95.74%
收藏
 问题点数:0 回复次数:3 
我也发一个c语言实现 鼠标的功能
程序代码:
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "graphics.h"
#include "dos.h"
#include "math.h"
int init();
void tu();
float x=20,y=240;
int x1,y1;
  int n=1,old_n;
  int start=0;
union REGS regs;
void main()
{int gr=DETECT,gm;
        initgraph(&gr,&gm,"c:\\jmsoft\\drv");\*这里要改成你编译器的位置*\
        init_mouse();
        while(!kbhit())
        tu();   
}
void tu()
{init();
        setcolor(RED);
        mouse_read();
        setcolor(RED);
    circle(x,y,24);
    switch(n)
  { case 1:old_n=1;line(x-12*sqrt(2),y-12*sqrt(2),x+12*sqrt(2),y+12*sqrt(2));
          n=2;break;
     case 2:old_n=2;line(x,y-24,x,y+24);n=3;break;
   case 3:old_n=3;line(x+12*sqrt(2),y-12*sqrt(2),x-12*sqrt(2),y+12*sqrt(2));
   n=4;break;
   case 4:old_n=4;line(x-24,y,x+24,y);n=1;
   break;
  }
    delay(10000);
    setcolor(BLACK);
    circle(x,y,24);
   switch(old_n)
   {case 1:line(x-12*sqrt(2),y-12*sqrt(2),x+12*sqrt(2),y+12*sqrt(2));
          n=2;break;
     case 2:line(x,y-24,x,y+24);n=3;break;
   case 3:line(x+12*sqrt(2),y-12*sqrt(2),x-12*sqrt(2),y+12*sqrt(2));
   n=4;break;
   case 4:line(x-24,y,x+24,y);
   break;}
   if(start==1&&x1<240&&x1>200&&y1>80&&y1<150)
    x+=3;       
}
init()
{int i,n;
        char str[20]="start";
        srand(time(NULL));
        n=rand()%6+1;
        setcolor(n);
        outtextxy(200,100,str);
}
int init_mouse()
{       
regs.x.ax=0;
int86(0x33,&regs,&regs);
regs.x.ax=4;
x1=regs.x.cx=320;
y1=regs.x.dx=240;
int86(0x33,&regs,&regs);
setcolor(GREEN);
circle(x1,y1,6);
putpixel(x1,y1,RED);
line(x1,y1+6,x1,y-6);
line(x1-6,y1,x1+6,y);
}
int mouse_read()
{delay(1000);
        regs.x.ax=3;
        int86(0x33,&regs,&regs);
        setcolor(BLACK);
circle(x1,y1,6);
putpixel(x1,y1,RED);
line(x1,y1+6,x1,y1-6);
line(x1-6,y1,x1+6,y1);
delay(1000);
        x1=regs.x.cx;
        y1=regs.x.dx;
        if(regs.x.bx==1)
        if((x1>=1))
        start=1;
        setcolor(BLUE);
circle(x1,y1,6);
putpixel(x1,y1,RED);
line(x1,y1+6,x1,y1-6);
line(x1-6,y1,x1+6,y1);
}
       
        
搜索更多相关主题的帖子: c语言 
2011-04-14 07:30
绝望生鱼片zm
Rank: 1
来 自:China
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-11-3
收藏
得分:0 
感谢楼主分享啊
2011-04-14 09:05
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
收藏
得分:0 
回复 2楼 绝望生鱼片zm
这个只是我学习鼠标的后写的。写的很烂的

用心做一件事情就这么简单
2011-04-14 12:51
Alar30
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:10
帖 子:988
专家分:1627
注 册:2009-9-8
收藏
得分:0 
不错哦
呵呵
2011-04-14 13:27
快速回复:我也发一个c语言实现 鼠标的功能
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018320 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved