C# WinForm开发 取消窗体关闭按钮
//禁用窗体的关闭按钮
private const int CP_NOCLOSE_BUTTON = 0x200;
protected override CreateParams CreateParams
{
get
{
CreateParams myCp = base.CreateParams;
myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
return myCp;
}
}
public Form1()
{
InitializeComponent();
this.ControlBox = false; // 设置不出现关闭按钮
}