C # Create borderless, freeform form, move without border form

Source: Internet
Author: User
Tags transparent color


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

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.