This article describes two methods for Winform to implement the failure of the close button. Share it for your reference. The details are as follows:
The first type:
protected override void WndProc(ref Message m) { const int WM_SYSCOMMAND = 0x0112; const int SC_CLOSE = 0xF060; if ( == WM_SYSCOMMAND && (int) == SC_CLOSE) { return; } (ref m); }
This method still allows the form's closing button to exist, but the mouse has no effect in operating the closing button. This method usually occurs when the system uses third-party controls, and other methods occur to invalidate the disable close button, but this method can ensure that there is no accident. (For example, after the system uses the skin control, it loads other methods to disable the form's closing button. At this time, you will find that the form's closing button is disabled ineffective. So, use this method)
The second type:
protected override CreateParams CreateParams { get { int CS_NOCLOSE = 0×200; CreateParams parameters = ; |= CS_NOCLOSE; return parameters; } }
I hope this article will be helpful to everyone's C# programming.