zoukankan      html  css  js  c++  java
  • Winform 无边框窗口移动自定义边框粗细颜色

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 
    11 namespace WinGPChat.master
    12 {
    13     public partial class formBase : Form
    14     {
    15         public formBase()
    16         {
    17             InitializeComponent();            
    18         }
    19         private Point mPoint = new Point();
    20         private void formBase_Load(object sender, EventArgs e)
    21         {
    22             this.MouseDown+=formBase_MouseDown;
    23             this.MouseMove+=formBase_MouseMove;            
    24         }
    25 
    26         protected void formBase_MouseMove(object sender, MouseEventArgs e)
    27         {
    28             if (e.Button == MouseButtons.Left)
    29             {
    30                 Point myPosittion = MousePosition;
    31                 myPosittion.Offset(-mPoint.X, -mPoint.Y);
    32                 this.FindForm().Location = myPosittion;
    33             }
    34         }
    35 
    36         protected void formBase_MouseDown(object sender, MouseEventArgs e)
    37         {
    38             mPoint.X = e.X;
    39             mPoint.Y = e.Y;
    40         }
    41 
    42         /// <summary>
    43         /// 重写Paint实现细边框
    44         /// </summary>
    45         /// <param name="e"></param>
    46         protected override void OnPaint(PaintEventArgs e)
    47         {
    48             Pen pen = new Pen(Color.Gray,1);
    49             e.Graphics.DrawLine(pen, new Point(0, 0), new Point(this.Width-1, 0));   //
    50             e.Graphics.DrawLine(pen, new Point(0, 0), new Point(0, this.Height-1));  //
    51             e.Graphics.DrawLine(pen, new Point(this.Width-1, 0), new Point(this.Width-1, this.Height-1));//
    52             e.Graphics.DrawLine(pen, new Point(0, this.Height-1), new Point(this.Width-1, this.Height-1));//
    53             base.OnPaint(e);
    54         }
    55 
    56         /// <summary>
    57         /// 无边框重写点击icon实现窗体最大化和最小化
    58         /// </summary>
    59         protected override CreateParams CreateParams
    60         {
    61             get
    62             {
    63                 CreateParams cp = base.CreateParams;
    64                 cp.Style = cp.Style | 0x20000;//允许最小化操作
    65                 return cp;
    66             }
    67         }
    68 
    69            
    70     }
    71 }
  • 相关阅读:
    Git Bash主题配置
    vuex里mapState,mapGetters使用详解
    Vue基础汇总实践
    Chrome for Mac键盘快捷键!来自Google Chrome官网!
    Vue中ESlint配置文件.eslintrc文件
    axios的get,post方法
    正则表达式识别标记——包括它之间的标记
    关于如何在微信里面让video不全屏播放
    javascript执行机制
    防止表单多次提交方法之二
  • 原文地址:https://www.cnblogs.com/jieliu726/p/4674360.html
Copyright © 2011-2022 走看看