winform 窗体关闭按钮禁用、不显示最大化、最小化、关闭按钮 分类: WinForm 2014-12-22 16:09 82人阅读 评论(0) 收藏

关闭按钮禁用:

(1) FormClosing事件

private void Main_FormClosing(object sender, FormClosingEventArgs e) {
           e.Cancel = true;
        }

(2)截获关闭信息,实现屏蔽

protected override void WndProc(ref Message m) {
            const int syscommand = 0x112;
            const int sc_close = 0xf060;
            if (m.Msg == syscommand && (int)m.WParam == sc_close) {
                return;
            }
            base.WndProc(ref m);
        }


窗体不显示最大、小化、关闭按钮,只显示标题:

public Main() {
            InitializeComponent();
            this.ControlBox = false;
        }

说明:如果想关闭,调用  Application.Exit(); 即可。

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2014-12-22 16:09  Jackerson  阅读(273)  评论(0)    收藏  举报