Class CHelloView :public CCoeControl
{
Public :
Static CHelloView* NewL(const TRect& aRect);
~CHelloView();
Void ConstructL(const TRect&)
Private:
Void Draw(const TRect) const;
Private:
HBufC* iHelloText;
}
Void CHelloView ::ConstructL(const CCoeControl& aContainer,const TRect& aRect){
SetContainerWindowL(aContainer);//说明CHelloView是aContainer
//的一个寄宿控件;
setRect(aRect);
………….
}
还要在主控件即aContainer 中改写 CCoeControl * ComponentControl(TInt aIndex) const
;以及TInt CountComponentControls() const;ComponentControl()中使用一个开关语句,返回从0开始的每一个索引对应的控件。CountComponentControls返回控件个数。
注意在控件进行重绘前,一定要把要重绘的区域设置为无效区域,否则将不会重绘。