close

using System;

using System.Windows.Forms;

using System.Runtime.InteropServices;

 

namespace WinFormMove

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

            this.MouseDown += new MouseEventHandler(this.MouseDown1);

            this.MouseMove += new MouseEventHandler(this.MouseMove1);

        }

 

        private void Form1_Load(object sender, EventArgs e){}

 

        [DllImport("user32.dll")]

        public static extern bool ReleaseCapture();

        [DllImport("user32.dll")]

        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

        public const int WM_SYSCOMMAND = 0X0112;

        public const int SC_MOVE = 0XF010;

        public const int HTCAPTION = 0X0002;

        private void MouseDown1(object sender, MouseEventArgs e)

        {

            if (e.Y > 65)

                return;

            ReleaseCapture();

            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);

        }

        private void MouseMove1(object sender, MouseEventArgs e)

        {

            if (e.Y < 65)

                this.Cursor = Cursors.SizeAll;

            else

                this.Cursor = Cursors.Default;

        }

    }

}

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Big Bear 的頭像
    Big Bear

    Programs Knowledge

    Big Bear 發表在 痞客邦 留言(0) 人氣()