C#非矩形窗体实现方法

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

(0)

相关推荐

  • C#实现更改MDI窗体背景颜色的方法

    本文实例讲述了C#实现更改MDI窗体背景颜色的方法.分享给大家供大家参考.具体实现方法如下: /// <summary> /// 设置MDI背景 /// </summary> void RemoveMdiBackColor() { foreach (Control c in this.Controls) { if (c is MdiClient) { c.BackColor = this.BackColor; //颜色 c.BackgroundImage = this.Backgr

  • C#圆角窗体简单实现方法

    本文实例讲述了C#圆角窗体简单实现方法.分享给大家供大家参考.具体如下: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Resize(object sender, EventArgs e) { Type(this, 25, 0.1); } private void Type(Control sender, int p_1, double p_2) {

  • C# 开发圆角控件(窗体)的具体实现

    最近在做卡片视图的程序,要求将控件做成带有圆角的效果,下面是我在网上查找的资料,经过测试,确定可以实现功能.其中方法三既适应于控件,也适应于窗体. 先上传效果图: 方法一: 增加命名空间:using System.Drawing.Drawing2D;  添加方法如下:当然各角的点可根据需要确定. 复制代码 代码如下: private void Type(Control sender, int p_1, double p_2)        {            GraphicsPath oP

  • C#禁用双击窗体图标关闭窗体的方法

    本文实例讲述了C#禁用双击窗体图标关闭窗体的方法.分享给大家供大家参考.具体实现方法如下: [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); protected override void WndProc(ref Message m) { if (m.Msg == 0x112) { if (m.WParam.ToInt32() == 61539

  • c#窗体传值用法实例详解

    本文实例讲述了c#窗体传值用法.分享给大家供大家参考.具体分析如下: 对于窗体间的数据传递,是刚开始从事.Net窗体应用程序开发人员碰到的一个常见问题,在此讲几个常见的实现方式.此节内容适用于模式窗体或非模式窗体,部分方式延伸到一般类的操作. (1)构造函数参数传递 通过构造函数传递参数应该是比较基本的参数传递方式,重载构造函数,通过带参数的构造函数来实例化窗体. 在窗体类内部定义参数变量, private object myParams; 实现构造函数, public OptionForm(o

  • C#画圆角矩形的方法

    本文实例讲述了C#画圆角矩形的方法.分享给大家供大家参考.具体实现方法如下: protected void Page_Load(object sender, EventArgs e) { Bitmap bm = new Bitmap(800, 600); Graphics g = Graphics.FromImage(bm); g.FillRectangle(Brushes.White,new Rectangle(0,0,800,600)); FillRoundRectangle(g,Brush

  • C#透明窗体实现方法

    本文实例讲述了C#透明窗体实现方法.分享给大家供大家参考.具体实现方法如下: namespace WindowsApplication1 { public partial class Form2 : Form { public Form2() { InitializeComponent(); this.Opacity = 1; this.Text = "opacity=1"; this.TopMost = true; } private void Form2_Activated(obj

  • C#窗体显示留言时间的方法

    本文实例讲述了C#窗体显示留言时间的方法.分享给大家供大家参考.具体分析如下: 运行平台:Vs2012 主要实现例如空间发表说说时间的显示,如:某人在10秒前回复了你这种效果 可用在Web浏览器,窗体,等... 复制代码 代码如下: namespace test {     class Program     {         static void Main(string[] args)         {             DateTime now = DateTime.Now;  

  • C#非矩形窗体实现方法

    本文实例讲述了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 Win

  • 浅谈C# 非模式窗体show()和模式窗体showdialog()的区别

    对话框不是模式就是无模式的.模式对话框,在可以继续操作应用程序的其他部分之前,必须被关闭(隐藏或卸载).例如,如果一个对话框,在可以切换到其它窗 体或对话框之前要求先单击"确定"或"取消",则它就是模式的. 一.如何调用 任何窗体(派生于基类Form的类),都可以以两种方式进行显示. //非模式窗体 From qform=new Form(); qform.Show(); //模式窗体 Form qform=new Form(); qform.ShowDialog(

  • 详解Vue 非父子组件通信方法(非Vuex)

    一提到两个非父子组件通信方法,有经验的 coder 肯定会说用 Vuex 啊,我个人建议不要为了用 Vuex 而用 Vuex,除非你的项目很大,耦合度很高,需要大量的储存一些 data,组件之间通信频繁.当然还是要根据自己的业务场景的来决定,总之还是那句话,不要为了用 Vuex 而用 Vuex! Vue 官网介绍了非父子组件通信方法: 不过官网说的太简单了,新手看完估计还是一脸懵逼.还有这个空的 Vue 实例放到哪里合适也值得商榷. 这篇文章的目的就是用一个简单的例子让你明白如何用 Bus

  • php通过array_merge()函数合并关联和非关联数组的方法

    本文实例讲述了php通过array_merge()函数合并关联和非关联数组的方法.分享给大家供大家参考.具体分析如下: array_merge()是一个用于合并数组的php函数,后一个数组追加到前一个的结束位置并返回合并后的结果数组. <?php $beginning = 'foo'; $end = array(1 => 'bar'); $result = array_merge((array)$beginning, (array)$end); print_r($result); ?>

  • python清除字符串里非字母字符的方法

    本文实例讲述了python清除字符串里非字母字符的方法.分享给大家供大家参考.具体如下: s = "hello world! how are you? 0" # Short version print filter(lambda c: c.isalpha(), s) # Faster version for long ASCII strings: id_tab = "".join(map(chr, xrange(256))) tostrip = "&quo

  • C#中登录窗体和欢迎窗体关闭方法分析

    本文实例分析了C#中登录窗体和欢迎窗体关闭方法.分享给大家供大家参考.具体分析如下: 在c#的winform编程中,我们经常会做登录窗体或欢迎窗体,并把他们作为启动窗体.   但是,我们有可能会遇到一些问题.   请看下面的代码: 复制代码 代码如下: private void button1_Click(object sender, EventArgs e) {     this.Close();     new Form2().Show(); } 这段代码想让form1中的button1在点

  • 在类库或winform项目中打开另一个winform项目窗体的方法

    本文实例讲述了在类库或winform项目中打开另一个winform项目窗体的方法.分享给大家供大家参考.具体如下: 一.问题: 假设类库或winform项目为A,另一个winform项目为B.那麽在A中添加一个接口,里面有一个Show方法,然后在B中写一个类b继承这个接口,并重写这个方法,具体内容为弹出某个窗体.然后在A中另一个类a中实例化B中的b类,并把它赋给A中的接口,然后调用接口的Show方法就可以弹出B中指定的窗体. 需要注意的是项目A和项目B需要互相引入对方的EXE或DLL文件. 二.

  • C#实现在Form里面内嵌dos窗体的方法

    本文实例讲述了C#实现在Form里面内嵌dos窗体的方法.分享给大家供大家参考.具体如下: using System; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Diagnostics; namespace cmdForm { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

  • MFC绘制不规则窗体的方法

    本文实例讲述了MFC 绘制不规则窗体的方法.分享给大家供大家参考.具体分析如下: 实现过程: 1.首先创建基于DLG的MFC应用程序,命名为:tryBGDlg,并将DLG的属性设置为:Title Bar :False ,其它设置不变 2.制作两幅图像,其中的一幅黑白图像,是根据播放器外观来制作的,其中白色区域是要保留的最终在桌面上显示的区域.将这两幅图像添加到工程中,第一个ID号设置为IDB_INTERFACE,第二个ID号设置为:IDB_MASK 3.在CtryBGDlg类中添加一个在函数:

  • python非递归全排列实现方法

    刚刚开始学习python,当前看到了函数这一节.结合数组操作,写了个非递归的全排列生成.原理是插入法,也就是在一个有n个元素的已有排列中,后加入的元素,依次在前,中,后的每一个位置插入,生成n+1个新的全排列.因为Python切割数组或者字符串,以及合并比较方便,所以,程序会节省很多代码. def getArrayInsertCharToStr(STR,CHAR): arr =[] s_len = len(STR) index =0 while index <= s_len: #分割字符串 ar

随机推荐