zoukankan      html  css  js  c++  java
  • 圆角窗口绘制

            对于form, 当BorderStyle = None时, 绘制圆角, 需要使用graphicspath的AddArc方法。

            程序如下

           protected override void OnPaint(PaintEventArgs e)
           {
                base.OnPaint(e);
                //圆弧半径
                int iRadius = 7;
                //边框工作区
                Rectangle rect = this.ClientRectangle;
                GraphicsPath path= new GraphicsPath();
                // 添加圆弧
                path.AddArc(0, 0, iRadius* 2, iRadius* 2, 180, 90);
                path.AddArc(rect.Width - iRadius* 2-1, 0, iRadius* 2, iRadius* 2, 270, 90);
                path.AddArc(rect.Width - iRadius* 2-1,  rect.Height - iRadius* 2-1, iRadius* 2, iRadius* 2, 0, 90);
                path.AddArc(0, rect.Height - iRadius* 2-1, iRadius* 2, iRadius* 2, 90, 90);
                path.CloseFigure();
                e.Graphics.DrawPath(SystemPens.ActiveBorder, path);

            }
               
           

           从控件左边起点画可以出席那边框,但是当从控件右边框使用 理论值画时,右边框不会出现边框,不清楚是为什么,我只好把横坐标左移1像素,即(rect.Height - iRadius * 2-1), 可以出现边框。

     如果周围有多个控件,看不到边框效果,可以适当修改Pen.Width=2 ,不要太大,否则边框加粗

  • 相关阅读:
    jsp完成页面自动刷新
    ssm整合案例
    MySql 里的IFNULL、NULLIF和ISNULL用法
    数据库优化
    数据库读写并发控制
    solr入门
    AngularJS入门(一)
    jsp和html的的区别
    Docker 网络(十一)
    Docker 容器资源隔离 namespace(十)
  • 原文地址:https://www.cnblogs.com/jason2004/p/6112261.html
Copyright © 2011-2022 走看看