• winform 拖动无边框窗体(调用Windows API)


    第一步:将窗体的FormBoderStyle属性设置为None;

    第二步:添加一个新类:Win32.cs

    代码如下:

    1 public class Win32
    2     {
    3         [DllImport("user32.dll")]
    4         public static extern bool ReleaseCapture();
    5 
    6         [DllImport("user32.dll")]
    7         public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
    8     }

    第三步:激活窗体的MouseDown事件

    代码如下:

    private void Form1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    Win32.ReleaseCapture();
                    Win32.SendMessage(Handle, 274, 61440 + 9, 0);
                }
            }

    完成!!

  • 相关阅读:
    python_day_5:20180720
    python_day_4:20180719
    2018悦读
    2018生活
    心理画
    js 策略模式
    js 单例模式
    js 模板方法模式
    C语言-数据类型
    js 观察者模式
  • 原文地址:https://www.cnblogs.com/LJSL/p/3476818.html
Copyright © 2020-2023  润新知