在子对话框上显示父对话框控件 [英] show parent dialog box controls on child dialog box
本文介绍了在子对话框上显示父对话框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在MFC中创建5-6个对话框,但是每个对话框上都有一些通用控件,因此我正在考虑创建一个包含这些通用控件的父对话框,其他对话框将从该父对话框继承. br/>
例如
Hi,
I want to create 5-6 dialog boxes in MFC, but there are some common controls on each dialog box, so i am thinking to create one parent dialog box which will contain these common controls and others will inherit from this parent dialog box.
e.g.
class CParentDlg:public CDialog {
//common controls
}
class CChildDlg:public CParentDlg{
//child related specific controls
}
所以当我在子对话框上执行DoModal时,它还应该显示父控件.
那我们可以这样吗?如果是,怎么办?
[我已经以上述方式完成操作,但是未在子对话框上显示父对话框的控件]
so when i do DoModal on child dialog box, then it should also show the controls of parent.
so can we do like this? if yes how?
[i have done things in above manner, but it is not showing the parent dialog box''s controls on child dialog box]
推荐答案
;对话框资源不是类对象的一部分,也不是继承的.调用DoModal()
时,对话框资源将编译到可执行文件中并加载.据我所知,实现目标的唯一方法是使用公共对话框资源,然后在OnInitDialog()
函数中添加动态控件.您还可以查看常用对话框 [ ^ ]并创建可自定义的您自己的.
You cannot do it this way; dialog resources are not part of the class object and are not inherited. The dialog resource is compiled into the executable file and loaded when you invokeDoModal()
. As far as I know the only way to achieve what you want to do is to use a common dialog resource and then add dynamic controls in theOnInitDialog()
function. You could also take a look at the Common Dialogs[^] and create a customizable version of your own.
这篇关于在子对话框上显示父对话框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文