天天看點

c# winform 窗體移動

public const int WM_SYSCOMMAND = 0x0112;

        public const int SC_MOVE = 0xF010;

        public const int HTCAPTION = 0x0002;

        [DllImport("user32.dll", EntryPoint = "SendMessageA")]

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

        [DllImport("user32.dll")]

        private static extern int ReleaseCapture();

private void Form_MouseDown(object sender, MouseEventArgs e)

        {

            ReleaseCapture();

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

        }

本文轉自94cool部落格園部落格,原文連結:http://www.cnblogs.com/94cool/articles/1524863.html,如需轉載請自行聯系原作者