问题描述
嗨!
我设计了1个GUI,其中5个子窗口在tab中,1个编辑控件框在父窗口(包含tab)窗口。所以我的问题是有没有任何方法或我在子控件中访问该值的解决方案。
1.我使用了该编辑控件变量的static int数据类型。
2.使用父类调用该变量::控制名称。
3.定义一个对所有子窗口都通用的函数,并在子控件中用extern关键字声明它。
4.在子控件中调用该函数并将该控件的值作为Parent class :: control变量名传递。
5.编译应用程序,但在运行时只需要值0.
是有任何解决方案。
Hi!
I''ve design 1 GUI in which 5 child windows in tab & 1 edit control box in parent(tab containing)window.So my question is that is there any method or solution that I access that value in child controls.
1.I used the static int datatype of that edit control variable.
2.Call that variable with parent class::control name.
3.Define a function which will be common to all child windows & declare it with extern keyword in child control.
4.Call that function in child control & pass the value of that control as Parent class::control variable name.
5.An application is compiled,but at run time it take only value 0.
Is there any solution.
推荐答案
class CYourBaseTab;
class CParentDlg : public CDialog
{
// Exchange value of the edit control
CString m_cszEditValue;
//..
enum { countTabs = 3 };
CYourBaseTab* m_arTabs[countTabs]; // we have to allocate'n'create all these tabs
public:
//..
const CString& GetEditValue() const {
return cszEditValue;
}
};
class CYourBaseTab : public CSomeMFCBase
{
// Parent access for each tab
const CParentDlg& m_cParentDlg;
public:
CYourBaseTab(const CParentDlg& cDlg, ...)
: CSomeMFCBase(...)
, m_cParentDialog(cDlg)
{
//..
}
const CString& GetEditValue() const {
return m_cParentDialog.GetEditValue();
}
};
这篇关于在子(选项卡式)窗口中使用父对话控制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!