The interface layout is as follows:Add a PictureBox control to the form
have border form
No Border form
Code implementation:
Public partial class Form2:form {public Form2 () {InitializeComponent (); #region Create borderless, any style form private void Form2_load (object sender, EventArgs e) {this. TransparencyKey = Color.White; Sets the default transparent color of this. BackColor = this. TransparencyKey; Sets the background color of the current form to transparent this. FormBorderStyle = Formborderstyle.none; Hide form Border} #endregion #region control the movement//using System.Runtime.InteropServices of the borderless form; [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 Picturebox1_mousedown (object sender, MouseEventArgs e) {//const int wm_syscom Mand = 0x0112; The form moves int sc_move = 0xf010; int htcaption = 0x0002; ReleaseCapture (); SendMessage (this. Handle, Wm_syscommand, Sc_move + htcaption, 0); }////constant//int wm_syscommand = 0x0112; Change the size of the form//int wmsz_left = 0xf001; int wmsz_right = 0xf002; int wmsz_top = 0xf003; int wmsz_topleft = 0xf004; int wmsz_topright = 0xf005; int wmsz_bottom = 0xf006; int wmsz_bottomleft = 0xf007; int wmsz_bottomright = 0xf008; ReleaseCapture (); SendMessage (this. Handle, Wm_syscommand, Wmsz_bottom, 0); SendMessage (this. Handle, Wm_syscommand, wmsz_top, 0); #endregion}
PNG image Resources
C # Create borderless, freeform form, move without border form