资源描述:
《用c语言实现按钮新技术 》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、用C语言实现按钮新技术一、按钮显示原理按钮一般有按下和弹起两种状态,在3Dstudio中按钮也有这两种状态,ain(){intgdriver=DETECT.gmode=VGAHI:button*but,*but1.*but2.*bt,*but3,*but4,*but5,*but6,*but7;intch;initgraph(gdriver,gmode,"d:tc");setcolor(ScreenBkColor);setbkcolor(2);clrscr();ButtonDefine(but,50,50,600,400);putDownBu
2、tton(but);ButtonDefine(but1,150,200,200,250);ButtonDefine(but2,200+dis,200,250+dis,250);ButtonDefine(but3,250+2*dis,200,300+2*dis,250);ButtonDefine(but4,300+3*dis,200,350+3*dis,250);ButtonDefine(but5,350+4*dis,200,400+4*dis,250);ButtonDefine(but6,400+5*dis,200,450+5*dis,250
3、);ButtonDefine(but7,450+6*dis,200,500+6*dis,250);while(ch!=27){switch(ch)}case'1':ReleaseButton(but1);break;case'2':ReleaseButton(but2);break;case'3':ReleaseButton(but3);break;case'4':ReleaseButton(but4);break;case'5':ReleaseButton(but5);break;case'6':ReleaseButton(but6);br
4、eak;case'7':ReleaseButton(but7);break;}ch=getch();if(ch==27)break;se(delay);}closegraph():return0;}voidButtonDefine(button*bt.shortx1,shorty1,shortx2,shorty2){START-X=x1;START-Y=y1;END-X=x2;END-Y=y2;}voidReleaseButton(button*bt){inti,j;setcolor(7);setfillstyle(1,7);bar(STAR
5、T-X,START-Y,END-X,END-Y);setcolor(ButtonWhite);setfillstyle(1,7);bar(START-X+Grap,START-Y+Grap,END-X-Grap,END-Y-Grap);setcolor(15);for(j=0;j<=Grap;j++){line(START-X,j+START-Y,END-X-j,j+STAT-Y);}for(i=0,i<=Grap;j++){line(START-X+i,START-Y+Grap,START-X+i,END-Y-i);}setco
6、lor(ButtonBlack);for(j=0;j<Grap;j++)}line(END-X,j+END-Y-Grap,START-X+Grap-j,j+END-Y-Grap);}for(i=0,i<Grap;i++){line(i+END-X+Grap,END-Y-Grap,i+END+X-Grap,START-Y+Grap-i);}return;}voidPutDoe(longinti){i=0;while(i<=delay)i++;}button.htypedefstructButtonDef{shortx1;sho
7、rty1;shortx2;shorty2;}button;