zoukankan      html  css  js  c++  java
  • 移动无标题(边框)窗体

    之前看到过一个CSDN上的教程,移动无标题窗体很麻烦很麻烦,要不断重画窗体。
    使用这种FormBorderStyle设置为none的窗体,可以简单的实现自定义窗体皮肤,当然皮肤要自己做图片了。

    今天无意间发现了一个很简单的代码,调用了系统API
    在Program.cs中存在如下代码:

            [DllImport("user32.dll")]
            
    public static extern bool ReleaseCapture();
            [DllImport(
    "user32.dll")]
            
    public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

            
    public const int WM_SYSCOMMAND = 0x0112;
            
    public const int SC_MOVE = 0xF010;
            
    public const int HTCAPTION = 0x0002;

    然后在想要实现这样功能的窗体上打入如下代码:

    private void frmInputPsd_MouseDown(object sender, MouseEventArgs e)
            
    {
                
    //如果鼠标指针在标题栏范围内并且按下了鼠标左键,则触发移动标题栏方法
                if (e.Button == MouseButtons.Left && e.Y <= 25)
                
    {
                    Program.ReleaseCapture();
                    Program.SendMessage(
    this.Handle, Program.WM_SYSCOMMAND, Program.SC_MOVE + Program.HTCAPTION, 0);
                }

            }
  • 相关阅读:
    mysql安装脚本
    vim常用命令
    CentOS 6.5使用国内网易163的源
    053(七十五)
    053(七十四)
    053(七十三)
    053(七十二)
    053(七十一)
    053(七十)
    053(六十九)
  • 原文地址:https://www.cnblogs.com/top5/p/1723510.html
Copyright © 2011-2022 走看看