------- <a href="http://www.itheima.com" target="blank">Windows Phone 7手机开发</a>、<a href="http://www.itheima.com" target="blank">.Net培训</a>、期待与您交流! -------
1、导包:using System.Runtime.InteropServices;
2、将以下代码放入类中:
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtrhwnd,int wMsg,intwParam,int lParam);
public const intWM_SYSCOMMAND = 0x0112;
public const int SC_MOVE =0xF010;
public const int HTCAPTION =0x0002;
3、设置窗体鼠标按下事件,在事件方法中黏贴如下代码:
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);