1.首先编写一个方法,后面需要引用
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LoginInterface
{
class designForm
{
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwdn, int wMsg, int mParam, int IParam);
public void moveForm(IntPtr DBm )
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xF010;
const int HTCAPTION = 0x0002;
ReleaseCapture();
SendMessage(DBm, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
}
}