• 大小: 54KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-22
  • 语言: C#
  • 标签:

资源简介

目前网上的无边框窗体资源存在各种不足,或设计复杂效率低或功能缺少。总结整理所有能看到的,历时2月不断压缩代码, 功能非常完善,实现了最简洁的 拖拽、放大缩小、拉伸,代码没有使用WIN32 api 和gdi+也没有使用任何图片,代码只有120行非常高效,多个实现思路是独创性设计

资源截图

代码片段和文件信息


using System;
using System.Drawing;
using System.Windows.Forms;

namespace CustomFrom
{
    public partial class baseForm : Form
    {
        public baseForm()
        {
            InitializeComponent();
            //拉伸窗口
            this.MouseMove += new MouseEventHandler(Form_MouseMove);
            this.lbMin.MouseEnter += new EventHandler(btn_MouseEnter);
            this.lbMax.MouseEnter += new EventHandler(btn_MouseEnter);
            this.lbClose.MouseEnter += new EventHandler(btn_MouseEnter);
            this.lbMin.MouseLeave += new EventHandler(btn_MouseLeave);
            this.lbMax.MouseLeave += new EventHandler(btn_MouseLeave);
            this.lbClose.MouseLeave += new EventHandler(btn_MouseLeave);
        }
        #region 拉伸窗口
        private void Form_MouseMove(object sender MouseEventArgs e)
        {
            //Q3502120
            if (e.Button == MouseButtons.None)
            {
                if (e.Location.X >= this.Width - 5)
                {
                    if (e.Location.Y > this.Height - 5)
                        this.Cursor = Cursors.SizeNWSE;
                    else
                        this.Cursor = Cursors.SizeWE;
                }
                else if (e.Location.Y >= this.Height - 5)
                    this.Cursor = Cursors.SizeNS;
                else
                    this.Cursor = Cursors.Arrow;
            }
            else
            {
                if (this.Cursor == Cursors.SizeNWSE)
                {
                    this.Width = MousePosition.X - this.Left + 1;
                    this.Height = MousePosition.Y - this.Top + 1;
                }
                else if (this.Cursor == Cursors.SizeWE)
                    this.Width = MousePosition.X - this.Left;
                else if (this.Cursor == Cursors.SizeNS)
                    this.Height = MousePosition.Y - this.Top;
            }
        }

        #endregion

        #region titleBar
        private Point mousePoint = new Point();
        private void titleBar_MouseMove(object sender MouseEventArgs e)
        {
            base.onmousemove(e);
            if (e.Button == MouseButtons.Left)
            {
                if (this.WindowState == FormWindowState.Maximized)
                {
                    this.WindowState = FormWindowState.Normal;
                    return;
                }
                this.Top = Control.MousePosition.Y - mousePoint.Y;
                this.Left = Control.MousePosition.X - mousePoint.X;
            }
        }
        private void titleBar_MouseDown(object sender MouseEventArgs e)
        {
            base.onmousedown(e);
            this.mousePoint.X = e.X;
            this.mousePoint.Y = e.Y;
        }
        private void titleBar_MouseDoubleClick(object sender MouseEventArgs e)
        {
            WindowMax();
        }
        #endregion

        #region Label
        private void Wi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        189  2019-07-05 10:02  TestForm\App.config

     文件       9216  2019-07-05 10:18  TestForm\bin\Debug\baseForm.dll

     文件      17920  2019-07-05 10:18  TestForm\bin\Debug\baseForm.pdb

     文件       7168  2019-07-05 10:18  TestForm\bin\Debug\TestForm.exe

     文件        189  2019-07-05 10:02  TestForm\bin\Debug\TestForm.exe.config

     文件      17920  2019-07-05 10:18  TestForm\bin\Debug\TestForm.pdb

     文件        412  2019-07-05 10:02  TestForm\Form1.cs

     文件       1164  2019-07-05 10:02  TestForm\Form1.Designer.cs

     文件       6639  2019-07-05 10:18  TestForm\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7209  2019-07-05 10:02  TestForm\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2019-07-05 10:02  TestForm\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2019-07-05 10:02  TestForm\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2019-07-05 10:02  TestForm\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件          0  2019-07-05 10:18  TestForm\obj\Debug\TestForm.csproj.CopyComplete

     文件         42  2019-07-05 10:18  TestForm\obj\Debug\TestForm.csproj.CoreCompileInputs.cache

     文件        791  2019-07-05 10:18  TestForm\obj\Debug\TestForm.csproj.FileListAbsolute.txt

     文件        954  2019-07-05 10:18  TestForm\obj\Debug\TestForm.csproj.GenerateResource.Cache

     文件       7559  2019-07-05 10:18  TestForm\obj\Debug\TestForm.csprojResolveAssemblyReference.cache

     文件       7168  2019-07-05 10:18  TestForm\obj\Debug\TestForm.exe

     文件      17920  2019-07-05 10:18  TestForm\obj\Debug\TestForm.pdb

     文件        180  2019-07-05 10:18  TestForm\obj\Debug\TestForm.Properties.Resources.resources

     文件        520  2019-07-05 10:02  TestForm\Program.cs

     文件       1314  2019-07-05 10:02  TestForm\Properties\AssemblyInfo.cs

     文件       2829  2019-07-05 10:02  TestForm\Properties\Resources.Designer.cs

     文件       5612  2019-07-05 10:02  TestForm\Properties\Resources.resx

     文件       1095  2019-07-05 10:02  TestForm\Properties\Settings.Designer.cs

     文件        249  2019-07-05 10:02  TestForm\Properties\Settings.settings

     文件       3662  2019-07-05 10:02  TestForm\TestForm.csproj

     文件       1605  2019-07-05 10:02  baseForm.sln

     文件       4178  2019-07-05 10:18  baseForm\baseForm.cs

............此处省略35个文件信息

评论

共有 条评论