禁用关闭按钮而不隐藏控制框 [英] Disable the Close button without hiding the Controlbox
本文介绍了禁用关闭按钮而不隐藏控制框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序,我不希望用户能够关闭表单.好吧,很简单.只需为表单设置 ControlBox = false
即可.
I have an application where I do not want the user to be able to close the form. Okay, easy enough. Just set ControlBox = false
for the form.
但是,我想将应用程序图标保留在表单的左上角.次要我知道,但细节对我来说意义重大.
However, I would like to keep the application icon in the upper left corner of the form. Minor I know, but details mean something to me.
设置Controlbox = false
也会使应用程序的图标在表单的左上角消失.有没有办法解决这个问题??
Setting the Controlbox = false
also makes the application's icon go away in the upper left corner of the form. Is there a way around this??
推荐答案
这里是我使用的代码.
我的 VB.Net 版本.
My VB.Net version of it.
Private Const CP_NOCLOSE_BUTTON As Integer = &H200
Protected Overrides ReadOnly Property CreateParams() As Windows.Forms.CreateParams
Get
Dim mdiCp As Windows.Forms.CreateParams = MyBase.CreateParams
mdiCp.ClassStyle = mdiCp.ClassStyle Or CP_NOCLOSE_BUTTON
Return mdiCp
End Get
End Property
这篇关于禁用关闭按钮而不隐藏控制框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文