微信公众号 
图码生活

每天发布有五花八门的文章,各种有趣的知识等,期待您的订阅与参与
电脑报 1992-2001 十年文章全集
电脑报 1992-2001 十年文章全集
包含从 1992 年 - 2001 年间,两万余篇期刊文章,查询最少输入两个字符
随便看看
读取中
读取中
标题用C语言设计立体按钮
栏目基础知识与讲座
作者江苏 蔡天翊
发布1995-03-17
  #include<graphics.h>
  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();
  }