快速設置無標題欄進行拖動窗體

  ------- <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);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章