110,552
社区成员
发帖
与我相关
我的任务
分享
把控件当作标题栏,就能移动控件了
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);
[DllImport("user32.dll")]
private static extern bool ReleaseCapture();
private const UInt32 WM_NCLBUTTONDOWN = 0x00A1;
private const UInt32 HTCAPTION = 2;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(button1.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}