您的位置:首页 > 其它

关于方法CEikonEnv::Static()方法和宏iEikonEnv的使用区别

2010-01-29 18:24 337 查看
为了实现音乐文件的浏览,即查找功能,我们需要产生一个对话框窗口,如下:





真机运行时,该窗口之前还有一个选择手机或存贮卡的窗口,因为模拟器不具备扩展卡,所以直接显示上面这个窗口。
上面第一个窗口的显示是通过类MGFetch的RunL()方法产生。
第二个窗口的显示是通过iEikonEnv或者是CEikonEnv::Static()产生的。
那么iEikonEnv和CEikonEnv::Static()有什么使用区别,用谁更合适?



为了产生上面的第二个对话框。我们使用CEikonEnv::Static()方法,来获得控制控件环境的指针。以类CFileFetcher为例,我们给这个类定义一个private 成员 CEikonEnv* ivEikonEnv,在该类的构造函数中,我们进行初始化ivEikonEnv = CEikonEnv::Static(),这是一个静态方法。这样就可以在该类的成员函数中使用变量ivEikonEnv来控制控件环境,然后通过使用这个指针来操作对话框,即上面第二个图。
而iEikonEnv是个宏,它是在头文件eikdef.h中定义的:#define iEikonEnv (STATIC_CAST(CEikonEnv*,iCoeEnv)),从形式上看宏iEikonEnv就是一个CEikonEnv指针,但却不能直接拿来使用,这是值得进一步学习掌握的。





类MGFetcher中的static方法
IMPORT_C TBool RunL (CDesCArray &aSelectedFiles, TMediaFileType aMediaType, TBool aMultiSelect, MMGFetchVerifier *aVerifier=NULL)配合接口MMGFetcherVerifier使用,MMGFetcherVerifier的作用仅仅是为了判断有没有从窗口中选中一个文件,是,返回true;否,返回false;即方法TBool VerifySelectionL (const MDesCArray *aSelectedFiles);
其中参数aMultiSelect的作用是确定是选择一个或多个文件。
实际上最关键的是搞清楚类CCoeEnv、CEikonEnv、CAknEnv这几个的作用及相互关系:



给用户产生信息提示窗口,使用CEikonEnv::Static()->infoWinL();询问窗口使用
CEikonEnv::Static()->QueryWinL()




CCoeEnv:
Description
Control environment.
CCoeEnv provides an active environment for creating controls. It implements active objects and an active scheduler, which
provide access to the window server, simplifying the API for application programs. It also provides utility functions that
are useful to many applications.
When a standard event occurs, the active scheduler calls CCoeEnv::RunL(). When a redraw event occurs, it calls
CCoeRedrawer::RunL(). Priority key events must be accessed using the Window Server API directly.
Note:
Standard events are all events except redraw events and priority key events.
翻译:
控件环境
CCoeEnv为创建的控件提供了一个活动的环境,它实现了活动对象和活动调度器,以便访问窗口服务器,另外它还提供了一些对许多程序而言比
较有用的函数。
当一个标准的事件发生时,这个活动调度器会调用方法CCoeEnv::RunL(),而当一个重绘事件发生时,将调用方法CCoeRedrawer::RunL(),优先
的按键事件必须使用窗口服务器的API直接访问。
注意:除了重绘事件和优先按键的事件都是标准事件。
CEikonEnv:
Description
An environment for creating Uikon controls and utility functions for manipulating those controls. Every Uikon application is
provided with an instance of CEikonEnv by the framework, which can be accessed through either CEikonEnv::Static() or the
iEikonEnv macro of CEikApplication.
This class is not intended for user derivation.
翻译:为创建的UIkon控件提供一个环境,以及一些方便操作这些控件的函数。每一个UIkon程序都会由程序框架提供一个CEikonEnv实例,可以
通过CEikonEnv::Static()或宏iEikonEnv来访问这个实例。
这个类不能被继承。
MApaAppStarter
Description
An interface used by the Application Architecture server to start applications.
The class has no user accessible functions.
Members
Defined in MApaAppStarter:
StartAppL()
Notes:
CEikonEnv is derived from this class.
翻译:
这是一个被应用程序框架服务器创建程序的接口。这个类没有用户可以访问的函数。
只有一个成员函数StartAppL()

转贴:http://www.sf.org.cn/Article/symbiandev/200608/18856.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐