using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace MoveNoneBoderForm { public partial class Form3 : Form { public Form3() { InitializeComponent(); } #region 无边框窗体之拖动方法1 protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == 0x84) { switch (m.Result.ToInt32()) { case 1: m.Result = new IntPtr(2); break; } } } #endregion #region 方法2 //[DllImport("user32.dll", EntryPoint = "SendMessage")] //public static extern int SendMessage(int hWnd, int wMsg, int wParam, int lParam); //[DllImport("user32.dll", EntryPoint = "ReleaseCapture")] //public static extern int ReleaseCapture(); //public const int WM_SysCommand = 0x0112; //public const int SC_MOVE = 0xF012; //private void Form1_MouseDown(object sender, MouseEventArgs e) //{ // ReleaseCapture(); // SendMessage(this.Handle.ToInt32(), WM_SysCommand, SC_MOVE, 0); //} #endregion private void button1_Click(object sender, EventArgs e) { this.Close(); } } }