//form Move API, import namespaces first, in Delegate MouseDown event//Prepare before moving[DllImport ("user32.dll")] Public Static extern BOOLreleasecapture (); [DllImport ("user32.dll")] Public Static extern BOOLSendMessage (INTPTR hwnd,intWmsg,intWParam,intiparam); Public Const intWm_syscommand =0x0112; Public Const intSc_move =0xf010; Public Const intHtcaption =0x0002; [DllImport ("User32")]Private Static extern intSendMessage (INTPTR hwnd,intWmsg,intWParam, IntPtr lParam);Private Const intWm_setredraw =0xB;//form Move EventPrivate voidForm1_mousedown (Objectsender, MouseEventArgs e) { if( This. WindowState = =formwindowstate.normal) {releasecapture (); SendMessage ( This. Handle, Wm_syscommand, Sc_move +Htcaption,0); }}
Borderless form Mobile API
Copy the API code to the form code structure function, reference the namespace, Delegate MouseDown event (Lee brainstorming Lxc)
//The form Shadow API, placed above the structure function, modifies the structure function to Const intCs_dropshadow =0x20000; Const intGcl_style = (- -); [DllImport ("user32.dll", CharSet =CharSet.Auto)] Public Static extern intSetclasslong (INTPTR hwnd,intNIndex,intDwnewlong); [DllImport ("user32.dll", CharSet =CharSet.Auto)] Public Static extern intGetclasslong (INTPTR hwnd,intNIndex); PublicForm1 () {InitializeComponent (); Setclasslong ( This. Handle, Gcl_style, Getclasslong ( This. Handle, Gcl_style) |Cs_dropshadow); }
form Shadow API
Copy the API code above the structure function and modify the structure function to
API-General Function interface
Make a form with no borders as follows
One or five border form move
Copy the API code to the form code structure function below, reference the namespace, delegate the MouseDown event
PublicForm1 () {InitializeComponent (); } //Form Mobile API[DllImport ("user32.dll")] Public Static extern BOOLreleasecapture (); [DllImport ("user32.dll")] Public Static extern BOOLSendMessage (INTPTR hwnd,intWmsg,intWParam,intIparam); Public Const intWm_syscommand =0x0112; Public Const intSc_move =0xf010; Public Const intHtcaption =0x0002; [DllImport ("User32")] Private Static extern intSendMessage (INTPTR hwnd,intWmsg,intWParam, IntPtr lParam); Private Const intWm_setredraw =0xB; Private voidForm1_mousedown (Objectsender, MouseEventArgs e) { if( This. WindowState = =formwindowstate.normal) {releasecapture (); SendMessage ( This. Handle, Wm_syscommand, Sc_move + htcaption,0); } }
no form move code after copying
Second, form Shadow
c#-winform-move and Shadow-api for borderless forms