Winform Remove the Maximize minimize close button (not turn off button dimmed) the ultimate solution

Source: Internet
Author: User

No ink,:

Online to see, a lot of answers garbled seven bad, are all nonsense, so write their own code as follows:
The size of the form is temporarily set to: (598, 362) The red data is changed according to your form size

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Drawing.Drawing2D;usingSystem.Runtime.InteropServices;namespacewindemo{ Public Partial classForm5:form { PublicFORM5 () {InitializeComponent (); }        /// <summary>        ///button to redraw the event/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidButton1_paint (Objectsender, PaintEventArgs e) {GraphicsPath MyPath=NewGraphicsPath (); Rectangle rect=NewRectangle (0,0,574,362);//back 2 data resizing form sizeMypath.addrectangle (rect);  This. Region =NewRegion (MyPath); } [DllImport ("user32.dll")]        Static extern intReleaseDC (IntPtr hWnd, IntPtr HDC); [DllImport ("User32.dll")]        Private Static externIntPtr GETWINDOWDC (IntPtr hWnd); protected Override voidWndProc (refSystem.Windows.Forms.Message m) {            Const intWm_ncpaint =0x85; Base. WndProc (refm); if(M.msg = =wm_ncpaint) {INTPTR hdc=GETWINDOWDC (M.hwnd); if((int) HDC! =0) {Graphics g=GRAPHICS.FROMHDC (HDC); Pen Pen1=NewPen (Color.FromArgb ( -, -, -)); Pen Pen2=NewPen (Color.FromArgb ( -, -, -)); Pen Pen3=NewPen (Color.FromArgb (212,208, $)); G.drawline (Pen1,573,0,573, the);//On the outsideG.drawline (Pen2,572,1,572,359);//the outermost second strip of whiteG.drawline (Pen3,571,2,571,359); G.drawline (Pen3,571,2,571,359);                    G.flush ();                ReleaseDC (M.hwnd, HDC); }            }        }        Private voidForm5_mousecapturechanged (Objectsender, EventArgs e) {Graphics g= This.            CreateGraphics (); Pen Pen1=NewPen (Color.FromArgb ( -, -, -)); Pen Pen2=NewPen (Color.FromArgb ( -, -, -)); Pen Pen3=NewPen (Color.FromArgb (212,208, $)); G.drawline (Pen1,573,0,573, the);//On the outsideG.drawline (Pen2,572,1,572,359);//the outermost second strip of whiteG.drawline (Pen3,571,2,571,359); G.drawline (Pen3,571,2,571,359);        G.flush (); }    }}

Original link: http://zydcomputer.blog.163.com/blog/static/12427188120121102021528/

Winform Remove the Maximize minimize close button (not turn off button dimmed) the ultimate solution

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.