winform学习(9)无边框拖动窗体

mac2022-06-30  89

去除边框

选中窗体,在属性中找到FormBorderStyle,设置为None

实现无边框拖动

  [DllImport("user32.dll")]        public static extern bool ReleaseCapture();        [DllImport("user32.dll")]        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);        private void Login_MouseDown(object sender, MouseEventArgs e)        {            ReleaseCapture();            SendMessage(this.Handle, 0x0112, 0xF012, 0);        }

给窗体添加MouseDown事件:Login_MouseDown,即可实现功能。

转载于:https://www.cnblogs.com/1016391912pm/p/11506789.html

最新回复(0)