using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ECT
{
public partial class NoCloseForm : FormBase
{
/// <summary>
/// 获取已设置无法关闭窗口创建参数。就是这里
/// </summary>
protected override CreateParams CreateParams
{
get
{
int CS_NOCLOSE = 0x200;
CreateParams parameters = base.CreateParams;
parameters.ClassStyle |= CS_NOCLOSE;

return parameters;
}
}


public NoCloseForm()
{
InitializeComponent();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ECT
{
public partial class NoCloseForm : FormBase
{
/// <summary>
/// 获取已设置无法关闭窗口创建参数。就是这里
/// </summary>
protected override CreateParams CreateParams
{
get
{
int CS_NOCLOSE = 0x200;
CreateParams parameters = base.CreateParams;
parameters.ClassStyle |= CS_NOCLOSE;
return parameters;
}
}

public NoCloseForm()
{
InitializeComponent();
}
}
}
本文介绍了一种在C#中实现窗体无法被关闭的方法,通过修改CreateParams的ClassStyle属性并设置CS_NOCLOSE标志来阻止用户通过标准方式关闭窗体。

607

被折叠的 条评论
为什么被折叠?



