资源描述:
《c语言课程设计_鼠标器》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、C语言课程设计_鼠标器/*为了让本实例尽可能简洁的突出鼠标编程,而不在其他方面过多分散读者的注意力。我忽略了很多实现的细节,读者对于可以在十进制编辑框中输入字符"F"之类的问题不要太吃惊。有兴趣的读者可以很容易的修正这个"bug"*/#include#include#include#include#include#include#defineHEX0#defineDEC1#defineOCT2#define
2、BIN3intindex=0,choice=0;/*初始化鼠标器*/voidinitmouse(){ _AX=0; geninterrupt(0x33);}/*显示鼠标光标*/voidshowmouse(){ _AX=1; geninterrupt(0x33);}/*隐藏鼠标*/voidhidemouse(){ _AX=2; geninterrupt(0x33);}/*取鼠标状态和鼠标位置*/voidgetmouse(int*button,int*x,int*y){ _AX=3; _BX=0; geninter
3、rupt(0x33); *button=_BL; *x=_CX; *y=_DX;}/*设置程序中的数字字符表*/intgetnum(charc){ int j; charalpha_set[36]="0123456789abcdefghijklmnopqrstuvwzyz"; for(j=0;j<36;j++) { if(alpha_set[j]==c) break; } return5j;}/*把任意radix进制的数,转换为十进制数*/unsignedlongconvert_to_decimal(ch
4、ar*_num,intradix){ inti,len; unsignedlongdec=0; len=strlen(_num); len--; for(i=0;_num[i]!=NULL;i++,len--) { dec+=(getnum(_num[i])*pow(radix,len)); } returndec;}/*在给定的坐标(x,y)的位置显示一个字符串*/voiddisplay(intx,inty,charstring[80]){ gotoxy(x,y); cprintf(string);}/*清
5、屏,并且把背景色设置为青绿色*/voidmake_screen_cyan(){ textbackground(CYAN); clrscr();}/*绘制程序的初始界面*/voidstart_screen(){ index=0; hidemouse(); make_screen_cyan(); textbackground(RED); textcolor(BLACK); display(20,1,"RadixConverterbyNILOYMONDAL."); display(10,2,"Email:-yiwei
6、@zju.edu.cn"); display(30,3,"PressEscapetoQuit"); textbackground(CYAN); display(10,5,"Hexadecimal:-"); display(10,7,"Decimal :-"); display(10,9,"Octal :-"); display(10,11,"Binary :-"); textbackground(BLUE); display(23,5,"
7、 "); display(23,7," "); display(23,9," "); display(23,11," "); if(choice==HEX)
8、 gotoxy(24,5); elseif(choice==DEC) gotoxy(24,7); elseif(choice==OCT) gotoxy(24,9); else5if(choice==BIN) gotoxy(24,11); showmouse();}voidmain(){ chartext[80]=" ",buffer[80]; charch,*charhex,