禁用对话框中的关闭按钮 [英] Disable close button in dialog
本文介绍了禁用对话框中的关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在一个简单的对话框中禁用关闭按钮?
谢谢
Vivek chauhan
Hi,
how to disabled close button in a simple dialog?
Thanks
Vivek chauhan
推荐答案
以下是一个在运行时启用/禁用关闭按钮的示例:
Here is an example for you that will enable/disable the close button in runtime:
BOOL bEnable = FALSE; // TRUE to enable and FALSE to disable
//.....
UINT nMenuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if(pSysMenu)
{
pSysMenu->EnableMenuItem(SC_CLOSE, nMenuf);
}
您需要将此代码放在适当的位置(即 OnInitDialog 您的对话框类的code>)。 :)
将CS_NOCLOSE添加到它的类样式。
Add CS_NOCLOSE to it's class style.
你可以使用
closebutton.EnableWindow(0);
其中closebutton是控件的变量名。
You can use
closebutton.EnableWindow(0);
where closebutton is the variable name of the control.
这篇关于禁用对话框中的关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文