zoukankan      html  css  js  c++  java
  • 通过调用API函数实现的无边框窗体的拖拽,比判断坐标更快捷

    在winform程序中,有时会选择边框设计会none,但是这样就不能拖拽窗体移动

    解决方案有二;

    1,判断坐标控制拖拽

    2.利用API函数,

    下面介绍利用API函数,方便,快捷

    #region 移动无边框窗体事件
            private void form1_MouseDown(object sender, MouseEventArgs e)
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);//*********************调用移动无窗体控件函数
            }
    #endregion
    
     
    
    #region 拖动无边框窗体
            [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;
    #endregion
    这样就能轻松实现窗体拖拽!

  • 相关阅读:
    循环神经网络(Recurrent Neural Network)
    特征选择
    程序猿能挣多少钱
    python socket
    python 2 encode and decode
    pandas series
    source collection list
    pep8摘要
    python 正则表达式
    django显示图片
  • 原文地址:https://www.cnblogs.com/fanxingthink/p/4176167.html
Copyright © 2011-2022 走看看