Disable and enable the close button on Windows form
1 public partial class form1: Form
2 {
3 private bool isenableclosebutton = false;
4 Public form1 (string strflag)
5 {
6 initializecomponent ();
7 if (strflag = "no ")
8 {
9 This. lbl_closebuttonisenabled.text = "the close button in the upper right corner of the form is invalid ";
10 This. isenableclosebutton = false;
11}
12 else
13 {
14 This. lbl_closebuttonisenabled.text = "you can close the form by clicking the close button in the upper right corner of the form ";
15 this. isenableclosebutton = true;
16}
17}
18
19 protected override createparams
20 {
21 get
22 {
23 if (isenableclosebutton)
24 {
25 createparams parameters = base. createparams;
26 return parameters;
27}
28 else
29 {
30 int cs_noclose = 0x200;
31 createparams parameters = base. createparams;
32 parameters. classstyle | = cs_noclose;
33 return parameters;
34}
35}
36}
37}