Winform Minimize maximize off click on taskbar hide Show Click left mouse button to move form

Source: Internet
Author: User

One maximization

Two minimization

Three off

Four click on taskbar to hide display

Five Click the left mouse button to move the form

  #region UI settings Maximize, minimize, close, mouse Move window, click Taskbar Toggle window This.pnlMin.MouseHover + = new EventHandler (pnlmin_mousemove);//Minimize Press Button's mouse over style Change event This.pnlMin.MouseLeave + = new EventHandler (pnlmin_mouseleave);//Minimize button mouse leave style Change event THIS.P Nlmin.click + = new EventHandler (pnlmin_click);//Minimize button click event This.pnlMax.MouseHover + = new EventHandler (Pnlmax_mou            Semove)///Minimize button's mouse over style Change event This.pnlMax.MouseLeave + = new EventHandler (pnlmax_mouseleave);//Minimize button mouse leave style Change event This.pnlMax.Click + = new EventHandler (pnlmax_click);//Minimize button click event This.pnlClose.MouseHover + = new Eventha Ndler (pnlclose_mousemove);//The style changes when the mouse passes the close button This.pnlClose.MouseLeave + = new EventHandler (pnlclose_mouseleave);// The mouse leaves the Close button event This.pnlClose.Click + = new EventHandler (pnlclose_click);//Close button's Click event This.pnlHead1.MouseDo  WN + = new MouseEventHandler (Sysset_mousedown); Mouse move form position This.pnlHead1.MouseMove + = new MouseEventHandler (sysset_mousemove);//mouse move form bitThis.pnlHead1.MouseUp + = new MouseEventHandler (sysset_mouseup)//mouse move form position #endregion 

  

  #regionMaximize UI settings, minimize, close, mouse Move window, click Taskbar Toggle Window#regionClick Taskbar to Minimizeprotected OverrideCreateParams CreateParams//click Taskbar for minimized and restored        {            Get            {                Const intWs_minimizebox =0x00020000; CreateParams CP=Base.                CreateParams; Cp. Style= CP. Style | Ws_minimizebox;//allow minimization of operations                returnCP; }        }        #endregion        #regionMinimize button//the mouse over the minimized button has changed style events        Private voidPnlmin_mousemove (Objectsender, EventArgs e) {tip. SetToolTip ( This. Pnlmin,"minimization of");  This. Pnlmin.backcolor = Color.FromArgb ( -,255,255,255); }        //Minimize button's mouse away change style event        Private voidPnlmin_mouseleave (Objectsender, EventArgs e) {             This. Pnlmin.backcolor =color.transparent; }        //Click events for minimized buttons        Private voidPnlmin_click (Objectsender, EventArgs e) {            if(WindowState! =formwindowstate.minimized) {WindowState=formwindowstate.minimized; }        }        #endregion        #regionMaximizePrivate voidPnlmax_mousemove (Objectsender, EventArgs e) {tip. SetToolTip ( This. Pnlmax,"maximized"); if(WindowState = =formwindowstate.maximized) {tip. SetToolTip ( This. Pnlmax,"Recovery"); }             This. Pnlmax.backcolor = Color.FromArgb ( -,0,0,0); }        //Minimize button's mouse away change style event        Private voidPnlmax_mouseleave (Objectsender, EventArgs e) {             This. Pnlmax.backcolor =color.transparent; }        //Click events for minimized buttons        Private voidPnlmax_click (Objectsender, EventArgs e) {            inth =Screen.PrimaryScreen.WorkingArea.Height; intW =Screen.PrimaryScreen.WorkingArea.Width; if(WindowState = =formwindowstate.normal) {//This . MaximumSize = new Size (w, h);//set the form to maximized to fullscreen                 This. MaximumSize =NewSize (Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);  This. Pnlmax.backgroundimage =Global:: Cnwin.Apps.Properties.Resources.max; //this.tbCnt.Dock = dockstyle.right; //this.pnlCnt.Height = h-10; //this.pnlCnt.Width = w-2; //this.sptCnt.Width = 260;                 This. Pnlmax.invalidate (); WindowState=formwindowstate.maximized; //pnlrslt.left = (W/2); //sptcnt.splitterdistance = 80; //dgvrslt.width = w-100;            }            Else            {                 This. FormBorderStyle =Formborderstyle.none;  This. Pnlmax.backgroundimage =Global:: Cnwin.Apps.Properties.Resources.max16; //this.pnlCnt.Height = 629; //this.pnlCnt.Width = 964;                 This. MaximumSize =NewSize (966,630);  This. Pnlmax.invalidate (); WindowState=Formwindowstate.normal;  This. Height =656; //pnlrslt.left = 420; //sptcnt.splitterdistance = 80; //dgvrslt.width = 840; //dgvrslt.height = 452; //pnlpage.top = 508;            }            //int width = 0; int clmsum = This.dgvRslt.Columns.Count;            ////adjusted for each column of the DataGridView            //for (int i = 0; i < clmsum; i++)//{            //    //adjust each column to auto-fit mode//This.dgvRslt.AutoResizeColumn (i, datagridviewautosizecolumnmode.allcells); //    //record the width of the entire DataGridView//width + = this.dgvrslt.columns[i].            Width; //}            ////Determine the width of the adjustment and the original width of the relationship, if the adjusted width is greater than the original set width,////Then set the DataGridView Column Auto-adjustment mode to the displayed column,////If it is less than the original set width, change the mode to fill.             //if (width > This.dgvRslt.Size.Width)//{            //This.dgvRslt.AutoSizeColumnsMode = datagridviewautosizecolumnsmode.displayedcells; //}            //Else//{            //    //This.dgvRslt.AutoSizeColumnsMode = Datagridviewautosizecolumnsmode.fill; //}            ////this. MaximizedBounds = Screen.PrimaryScreen.WorkingArea;        }        #endregion        #regionClose button//trigger style changes when the mouse passes the Close button        Private voidPnlclose_mousemove (Objectsender, EventArgs e) {tip. SetToolTip ( This. Pnlclose,"Close");  This. Pnlclose.backcolor =color.red; }        //Mouse away off button trigger style change        Private voidPnlclose_mouseleave (Objectsender, EventArgs e) {             This. Pnlclose.backcolor =color.transparent; }        protected voidPnlclose_click (Objectsender, EventArgs e) {frmmonitor LG=NewFrmmonitor (); Lg.            Dispose ();        Application.exit (); }        #endregion        #regionMouse Move Form Move//form Dragging        BOOLIsmousedown =false; Point CWPT=NewPoint ();//current form positionPoint cmpt =NewPoint ();//the current mouse press position        Private voidSysset_mousedown (Objectsender, MouseEventArgs e) {            if(E.button = =mousebuttons.left) {Ismousedown=true; CWPT= This.                Location; Cmpt=System.Windows.Forms.Control.MousePosition; }        }        Private voidSysset_mouseup (Objectsender, MouseEventArgs e) {Ismousedown=false; }        Private voidSysset_mousemove (Objectsender, MouseEventArgs e) {            intRangex =0, Rangey =0;//calculates the displacement of the current mouse cursor, allowing the form to be shifted at the same size            if(ismousedown) {Point pt=System.Windows.Forms.Control.MousePosition; Rangex= Cmpt. XPt.                X Rangey= Cmpt. YPt.                Y  This. Location =NewPoint (CWPT. X-rangex, CWPT. Yrangey); }        }        #endregion        #endregion

Winform Minimize maximize off click on taskbar hide Show Click left mouse button to move 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.