c# 禁用和启用windows form窗体上的关闭按钮
2009-04-24 13:16
429 查看
禁用和启用windows form窗体上的关闭按钮
1public 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 = "窗体右上角关闭按钮无效";
10 this.isEnableCloseButton = false;
11 }
12 else
13 {
14 this.lbl_CloseButtonIsEnabled.Text = "可以通过窗体右上角关闭按钮 关闭窗体";
15 this.isEnableCloseButton = true;
16 }
17 }
18
19 protected override CreateParams 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}
1public 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 = "窗体右上角关闭按钮无效";
10 this.isEnableCloseButton = false;
11 }
12 else
13 {
14 this.lbl_CloseButtonIsEnabled.Text = "可以通过窗体右上角关闭按钮 关闭窗体";
15 this.isEnableCloseButton = true;
16 }
17 }
18
19 protected override CreateParams 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}
相关文章推荐
- 禁用和启用windows form窗体上的关闭按钮
- C# Winform 禁用窗体关闭按钮
- C#禁用窗体的关闭按钮
- C#小程序:使用API禁用窗体关闭按钮
- C#使用API禁用/删除程序窗体的关闭菜单和按钮
- C#使用API禁用/删除程序窗体的关闭菜单和按钮
- Windows Form窗体的关闭按钮的启用与否
- C#使用API禁用/删除程序窗体的关闭菜单和按钮
- Windows Form窗体的关闭按钮的启用与否
- C#禁用窗体最大化按钮
- winform 窗体禁用关闭按钮的三种方法
- C#中如何去除窗体默认的关闭按钮?
- C# 屏蔽窗体关闭按钮
- C#窗体编程不显示最小化、最大化、关闭按钮的方法
- c# 做的登录窗体,登录成功后当前登录Form关闭,打开Main窗体,但Main窗体点关闭按钮后程序仍在进程怎么办
- C#中如何去除或屏蔽窗体默认的关闭按钮
- C#(VB.NET)操作Windows自带的防火墙 之 启用(开启)/禁用(关闭)防火墙
- c# 去掉Form窗口关闭按钮,保留窗体栏
- c#按钮透明及窗体关闭时产生透明渐变
- c# 控制台程序禁用关闭按钮完美解决