本文介绍了Windows窗体:如何隐藏关闭(X)按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个模式对话框,并需要隐藏的关闭(X)按钮,但我不能使用控制框= 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;
}
}
来源:<一个href=\"http://www.$c$cproject.com/KB/cs/DisableClose.aspx\">http://www.$c$cproject.com/KB/cs/DisableClose.aspx
这篇关于Windows窗体:如何隐藏关闭(X)按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!