可能重复:
How to make the Close button disabled in a windows Form using C# coding
我想在表单中禁用“关闭”按钮,任何人都可以帮助我。
答案 0 :(得分:0)
以下内容应该有所帮助:
[DllImport("user32.dll")]
private static extern int GetSystemMenu(int hwnd, int revert);
[DllImport("user32.dll")]
private static extern int GetMenuItemCount(int menu);
[DllImport("user32.dll")]
private static extern int RemoveMenu(int menu, int position, int flags);
private void DisableCloseButton()
{
int menu = GetSystemMenu(Handle.ToInt32(), 0);
int count = GetMenuItemCount(menu);
RemoveMenu(menu, count - 1, MF_DISABLED | MF_BYPOSITION);
}