欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#非矩形窗体实现方法

程序员文章站 2023-11-17 19:16:28
本文实例讲述了c#非矩形窗体实现方法。分享给大家供大家参考。具体实现方法如下: using system; using system.collections.g...

本文实例讲述了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#程序设计有所帮助。