110,531
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
private const int SC_MOVE = 0xF010;
private const int HTCAPTION = 0x0002;
private const int WM_SYSCOMMAND = 0x0112;
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
public Form1()
{
InitializeComponent();
userControl1.MouseDown += new MouseEventHandler(userControl1_MouseDown);
}
private void userControl1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
}