C# Form 关闭按钮灰化

 

可以通过调用API函数将关闭按钮灰化(不可用)

        [DllImport("user32")]
        public static extern IntPtr GetSystemMenu(IntPtr hwnd, int bRevert);

        [DllImport("user32")]
        public static extern int RemoveMenu(IntPtr hMenu, int nPosition, int wFlags);

        public const int MF_BYPOSITION = 0x400;

然后在窗体load事件里加入下面代码
            IntPtr close = GetSystemMenu(this.Handle, 0);
            RemoveMenu(close, 6, MF_BYPOSITION);
这样就能将关闭按钮灰化了。

原文地址:https://www.cnblogs.com/renfeng/p/3727838.html