zoukankan      html  css  js  c++  java
  • Winfrom实现圆角设计

    主要代码

     public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Paint(object sender, PaintEventArgs e)
            {
                Type(this, 25, 0.1);
            }

            private void Type(Control sender, int p_1, double p_2)
            {
                GraphicsPath oPath = new GraphicsPath();
                oPath.AddClosedCurve(new Point[] {
                    new Point(0, sender.Height / p_1),
                    new Point(sender.Width / p_1, 0),
                    new Point(sender.Width - sender.Width / p_1, 0),
                    new Point(sender.Width, sender.Height / p_1),
                    new Point(sender.Width, sender.Height - sender.Height / p_1),
                    new Point(sender.Width - sender.Width / p_1, sender.Height),
                    new Point(sender.Width / p_1, sender.Height),
                    new Point(0, sender.Height - sender.Height / p_1) },
                    (float)p_2); sender.Region = new Region(oPath);
            }

            private void Form1_Resize(object sender, EventArgs e)
            {
                Type(this, 25, 0.1);
            }


            Point _Location;
            Boolean _Down = false;
            private void Form1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    _Location = new Point(e.X, e.Y);
                    _Down = true;
                }
            }

            private void Form1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left && _Down == true)
                {
                    this.Left += e.X - _Location.X;
                    this.Top += e.Y - _Location.Y;
                }
            }

            private void Form1_MouseUp(object sender, MouseEventArgs e)
            {
                _Down = false;
            }
        }

  • 相关阅读:
    静态库与动态库的创建与使用
    MinGW 仿 linux 开发环境
    SICP 1.7-1.8 solution (Scheme)
    PHP 学生管理系统实现
    【2014最新】常用hosts集锦,分享给大家
    【Android快速入门3】布局简介及例子
    【Android快速入门2】拨号器的实现
    【Android快速入门1】目录结构及adb命令(以API19为例)
    基于深度及广度优先搜索的迷宫问题的演示
    基于HTML5的js构造爱心,动态时间校准
  • 原文地址:https://www.cnblogs.com/FLWL/p/6247720.html
Copyright © 2011-2022 走看看