在S60中,如果在Container类中添加控件,就必须实现下面几个必要方法:
TInt CountComponentControls() const;
CCoeControl* ComponentControl( TInt aIndex ) const;
void SizeChanged();
否则会出现控件无法正常刷新显示的问题。
举例:如使用Grid控件,定义一个 CAknGrid* iGrid
enum TUsedComponent
{
EGrid,
// add more component here...
ELastControl
};
TInt CMobileAssistantAppMainContainer :: CountComponentControls() const
{
return ELastControl; //返回当前使用的控件数量
}
CCoeControl* CMobileAssistantAppMainContainer :: ComponentControl( TInt aIndex ) const
{
switch ( aIndex )
{
case EGrid:
return iGrid; //如果有其他控件,再这里需要继续添加case语句
default:
return NULL;
}
}
void CMobileAssistantAppMainContainer :: SizeChanged()
{
if ( iGrid )
{
iGrid->SetRect( Rect() ); //刷新显示区域
}
}