This article describes the method of C# to implement borderless movement of Winform. Share it for your reference. The details are as follows:
const int HTLEFT = 10; const int HTRIGHT = 11; const int HTTOP = 12; const int HTTOPLEFT = 13; const int HTTOPRIGHT = 14; const int HTBOTTOM = 15; const int HTBOTTOMLEFT = 0x10; const int HTBOTTOMRIGHT = 17; protected override void WndProc(ref Message m) { switch () { case 0x0084: (ref m); Point vPoint = new Point((int) & 0xFFFF, (int) >> 16 & 0xFFFF); vPoint = PointToClient(vPoint); if ( <= 5) if ( <= 5) = (IntPtr)HTTOPLEFT; else if ( >= - 5) = (IntPtr)HTBOTTOMLEFT; else = (IntPtr)HTLEFT; else if ( >= - 5) if ( <= 5) = (IntPtr)HTTOPRIGHT; else if ( >= - 5) = (IntPtr)HTBOTTOMRIGHT; else = (IntPtr)HTRIGHT; else if ( <= 5) = (IntPtr)HTTOP; else if ( >= - 5) = (IntPtr)HTBOTTOM; break; case 0x0201://The message pressed by the left mouse button = 0x00A1;//Change the message to non-customer area and press the mouse = ;//default value = new IntPtr(2);//Put the mouse in the title bar (ref m); break; default: (ref m); break; } }
I hope this article will be helpful to everyone's C# programming.