[WinForm]使关闭按钮不可用或隐藏

时间:2014-07-07 09:33:54   收藏:0   阅读:254

关键代码:

        /// <summary>
        /// 代码源自:http://www.codeproject.com/Articles/20379/Disabling-Close-Button-on-Forms
        /// </summary>
        private const int CP_NOCLOSE_BUTTON = 0x200;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams _createParams = base.CreateParams;
                _createParams.ClassStyle = _createParams.ClassStyle | CP_NOCLOSE_BUTTON;
                return _createParams;
            }
        }

代码效果:

bubuko.com,布布扣

或者设置ControlBox属性来隐藏,如图:

bubuko.com,布布扣

希望有所帮助!

[WinForm]使关闭按钮不可用或隐藏,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!