C#窗体程序设置禁用关闭按钮

只要再程序里面增加如下代码即可:

/// <summary>
/// 禁用窗体关闭按钮
/// </summary>
/// <param name="m"></param>
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;

const int SC_CLOSE = 0xF060;

if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)
{
return;
}
base.WndProc(ref m);
}

posted @ 2020-03-09 15:00  LcVong  Views(99)  Comments(0Edit  收藏  举报