本文介绍了如何仅隐藏关闭(x)按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模式对话框,需要隐藏关闭(X)按钮,但是我不能使用
ControlBox = false ,因为我需要保持

I have a modal dialog, and need to hide the Close (X) button, but I cannot use ControlBox = false, because I need to keep the Minimize and Maximize buttons.

我只需要隐藏关闭按钮,有什么办法吗?

I need to hide just Close button, is there any way to do that?

非常感谢!

更新:我有权禁用它,这很简单:)谢谢!

Update: I had permission to disable it, which is simpler :) Thanks all!

推荐答案

您无法将其隐藏,但是可以通过覆盖表单的CreateParams属性来禁用它。

You can't hide it, but you can disable it by overriding the CreateParams property of the form.

private const int CP_NOCLOSE_BUTTON = 0x200;
protected override CreateParams CreateParams
{
    get
    {
       CreateParams myCp = base.CreateParams;
       myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON ;
       return myCp;
    }
}

来源:

这篇关于如何仅隐藏关闭(x)按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:40