控件的二阶段构造函数解决思路
发布时间:2010-05-30 00:30:56 文章来源:www.iduyao.cn 采编人员:星星草
控件的二阶段构造函数
初学Symbian编程,有一个小问题
ConstructL()函数是不是应该被设为private?
我在写一个小控件的时候
class CSymbian1Container : public CCoeControl
{
public:
static CSymbian1Container* NewL(const TRect& aRect,const CCoeControl* aParent);
static CSymbian1Container* NewLC(const TRect& aRect,const CCoeControl* aParent);
~CSymbian1Container();
void ConstructL(const TRect& aRect, const CCoeControl* aParent);
}
然后在另一个类CSymbian1AppUi
class CSymbian1AppUi : public CAknAppUi
{
public:
void ConstructL(void);
~CSymbian1AppUi();
}
这个类的ConstructL函数完成时出现问题
void CSymbian1AppUi::ConstructL(void) {
BaseConstructL();
iAppContainer = new (ELeave) CSymbian1Container;
iAppContainer-> SetMopParent( this );
iAppContainer-> ConstructL( ClientRect() );//here
AddToStackL( iAppContainer );
}
调用CSymbian1Container中的ConstructL时少了一个参数,就是const CCoeControl* aParent这个参数,我应该怎么加上呢?ClientRect() 又是什么函数呢?
感谢回答!
------解决方案--------------------
ConstructL是否要设为private根据需要而定,取决于你怎么传递参数。如果NewL,NewLC有了ConstructL所需要的参数,就可以将ConstructL设为private;否则,ConstructL需设为public,这时NewL,NewLC便没什么用了。
就你目前的应用来说,ConstructL的第二个参数没有必要,也没有用到NewL,NewLC。
如果一定要使用第二个参数,需将你自定义的Container放在另一个Container中,即parent。
ClientRect() 顾名思义,客户区矩形,Container的可见区域。
------解决方案--------------------
你用ConstructL,就不用CSymbian1Container* NewL(C);ConstructL里的参数 "const CCoeControl* aParent "不要了
ClientRect():
Gets the area of the screen available to the application for drawing.
This does not include the space available for UI components like the menu bar.
The co-ordinates of the rectangle are relative to the whole screen area so, for example, the co-ordinate for the top, left point of the area available for drawing may be (0, 45).
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
高手,求个S60v3 FP2 320*240分辨率的SDK
求个S60v3 FP2 320*240分辨率的SDK,
240*320的SDK虽然可以调分辨率的,但我想要一个和E72一...
-
请教关于smybian上使用sqlite的问题
请问如何在symbian 9.1版本上使用sqlite啊?
------解决方案--------------------
直接去sql...
-
symbian 可以内嵌浏览器吗
谁有内嵌浏览器的简单代码吗?或者如何实现内嵌浏览器。谢谢
------解决方案--------------------
ht...
-
symbian:如何判断一个文件是否系统支持的手机铃声格式
现在需要扫描一些固定后缀的文件如MP3,aac等显示出来供用户选择设置为手机铃...
-
数据库求助!!
我创建了一个RDbStoreDatabase,想把通讯录的数据库内容复制过来,该如何实现?实在是不想一条条的insert。。。
------解...
-
Specified file '\Symbian\9.1\S60_3rd_MR\EPOC32\RELEASE\WINSCW\UDEB\.lib' not found 什么意思?
请大家帮我解决一下,...
-
关于Symbian的express signed
我想给一个Symbian程序做一个express signed,在得到了publisheID后,还需要一个Content ID才能完成,可...
-
CPbkContactEngine::NewL()真机崩溃
如题,在模拟器上正常,在真机上崩溃
哪位遇到过?
------解决方案--------------------
我也遇...
-
请问在symbian如何获取最近手机基站的lac和cid?
请问在symbian如何获取最近手机基站的lac和cid?
------解决方案---------------...
-
求救rvct2.2问题:Cannot obtain license for Compiler (feature compiler) with license version >= 2.2
在carbide用rvct2.2编译...