当前位置: 移动技术网 > IT编程>开发语言>c# > C#非矩形窗体实现方法

C#非矩形窗体实现方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#非矩形窗体实现方法。分享给大家供大家参考。具体实现方法如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.drawing2d;
namespace windowsapplication1
{
  public partial class form3 : form
  {
    point downpoint = point.empty;
    public form3()
    {
      initializecomponent();
    }
    void set()
    {
      rectangle rect = this.clientrectangle;
      using (graphicspath path = new graphicspath())
      {
        path.addellipse(rect);
        this.region = new region(path);
      }
    }
    private void form3_load(object sender, eventargs e)
    {
      set();
    }
    private void form3_mousedown(object sender, mouseeventargs e)
    {
      if (e.button != mousebuttons.left) return;
      downpoint = new point(e.x, e.y);
    }
    private void form3_mousemove(object sender, mouseeventargs e)
    {
      if (downpoint == point.empty) return;
      point location = new point(this.left + e.x - downpoint.x, this.top + e.y - downpoint.y);
      this.location = location;
    }
    private void form3_mouseup(object sender, mouseeventargs e)
    {
      if (e.button != mousebuttons.left) return;
      downpoint = point.empty;
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网