日期:2014-05-18 浏览次数:21046 次
private System.Windows.Forms.Button button1; private bool Mousedown = false; //鼠标按下为true private int CurX = 0,CurY = 0;
------解决方案--------------------
[DllImport("user32.dll")] static extern bool ReleaseCapture(); [DllImport("user32.dll", CharSet = CharSet.Auto)] static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam); private readonly UInt32 WM_SYSCOMMAND = 0x112; private readonly UInt32 SC_MOVE = 0xF010; private readonly UInt32 HTCAPTION = 2; private void button1_Click(object sender, EventArgs e) { MessageBox.Show("1"); } private void button1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(button1.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); } }
------解决方案--------------------