对于包含子控件的对话框/控件,必须实现两个虚方法:CountComponentControls与ComponentControl。
CountComponentControls:返回子控件的数量ComponentControl:返回子控件的指针
Symbian中的复合控件不像MFC中的那样,会保存一个子控件列表。父窗口在绘制完自身后不会自动重绘子控件,它会调用 CountComponentControls获取子控件数量,然后从零开始依次把索引传给ComponentControl,得到一个子控件指针并调用其绘制过程。因此,如果不实现这两个方法,界面的刷新可能会有问题。
以下是代码示例:
TestDialog.h
TInt CountComponentControls() const;CCoeControl* ComponentControl(TInt aIndex) const;
private:
CEikEdwin *iEditor1;
CEikEdwin *iEditor2;
TestDialog.cpp
TInt CTestDialog::CountComponentControls() const{
return 2;
}
CCoeControl* CTestDialog::ComponentControl(TInt aIndex) const
{
if (aIndex == 0)
{
return iEditor1;
}
else if (aIndex == 1)
{
return iEditor2;
}
else
{
return NULL;
}
}