用C语言设计立体按钮 江苏 蔡天翊 1995-03-17 #include drawbutton(int left_x,int top_y,int right_x,int bottom_y,int linew,int col) /*本模块为画按钮函数*/ /*left_x,top_y为按钮左上角坐标,right_x,bottom_y为按钮右下角坐标*/ /*col为按钮颜色*/ /*linew为按钮的边框宽度*/ { int svcolor=getcolor(); /*返回当前画线颜色*/ struct fillsettingstype save; getfillsettings(&save); /*取得有关当前填充模式和填充颜色的信息*/ setfillstyle(SOLID_FILL,col); /*设置填充颜色*/ setcolor(col); /*设置画线颜色*/ bar(left_x,top_y,right_x,bottom_y); /*画实心方框*/ setcolor(svcolor); /*设置画线颜色*/ line(left_x,bottom_y-2,left_x,top_y); /*画方框外面左边的线*/ line(left_x,top_y,right_x,bottom_y); /*画方框外面左边的线*/ line(left_x+linew,bottom_y-linew,right_x-linew,bottom_y-linew; /* 画方框里面下边的线*/ line(right_x-linew,bottom_y-linew,right_x-linew,top_y+linew); /*画方框里面右边的线*/ setcolor(0); /*设置画线颜色*/ line(left_x+linew,top_y+linew,right_x-linew,top_y_linew); /*画方框里面左边的线*/ line(left_x+linew,bottom_y-linew,left_x+linew,top-y+linew; /*画方框里面上边的线*/ setcolor(svcolor); /*恢复原来的画线颜色*/ setfillstyle(save.pattern,save.color); /*恢复原来的填充模式和颜色*/ return; /*返回调用程序*/ } main() { int GraphDriver; int GraphMode; GraphDriver=DETECT; initgraph( &GraphDriver,&GraphMode,""); /*初使化图形屏幕*/ drawbutton(10,10,100,100,7,7); /*在屏幕左上角为(10,10)至*/ getch(); /*右下角为(100,100)处画一按钮*/ closegraph(); }