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

        private void MoveControl(Control sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && e.Clicks == 1)
            {
                ReleaseCapture();
                SendMessage(sender.Handle, 161, 2, 0);
                SendMessage(sender.Handle, 0x0202, 0, 0);
            }
            else
            {
                //添加双击或右击代码……
            }
        }

        private void button3_MouseDown(object sender, MouseEventArgs e)
        {
            MoveControl(sender as Control, e);
        }

 

相关文章:

  • 2021-08-18
  • 2021-04-27
  • 2021-09-25
  • 2021-09-27
  • 2022-12-23
猜你喜欢
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2021-06-26
  • 2022-12-23
相关资源
相似解决方案