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 ,不要太大,否则边框加粗

  • 相关阅读:
    oracle在没
    一天中时针和分钟重合的次数
    oracle的隐藏的东东
    左右小移动
    JS全选的操作
    JS定时器
    在文件中查找字符串
    表单原件
    div和span互换
    div和span的区别
  • 原文地址:https://www.cnblogs.com/jason2004/p/6112261.html
Copyright © 2011-2022 走看看