c#-winform-move and Shadow-api for borderless forms

Source: Internet
Author: User

//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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.