彻底解决Symbian全屏显示问题
来源:互联网 发布:深圳乐思软件 编辑:程序博客网 时间:2024/05/01 06:20
Author:孙东风 2007-04-06
最近总有同行问我Symbian全屏显示的问题,说是参考了网上的方法也无法设置成全屏。其实,归根结底还是不明白Symbian框架的调用机制。这篇文章里我就来彻底研究一下Symbian全屏的机制。
首先,我们可以利用Carbide.vs向导建一个项目,名字就叫"TestScreen",选择基于Eikon的传统控件架构。
那么在CTestScreenAppUi的二阶构造函数里就有如下代码:
void CTestScreenAppUi::ConstructL()
{
BaseConstructL();
iAppContainer = new (ELeave) CTestScreenContainer;
iAppContainer->SetMopParent( this );
iAppContainer->ConstructL( ClientRect() );
AddToStackL(iAppContainer);
}
这里面有很关键的一句,就是我用红色显示的那段代码。它把当前UI的ClientRect()传递给Container类,我们都知道Container类是控件类,负责整个程序的界面显示,那么UI传递给Container的这个ClientRect()到底是什么东东呢?我们看看SDK HELP:
ClientRect()
TRect ClientRect() const;
Description
Gets the area of the screen available to the application for drawing, not including the space that is available for any of the following, where required: non-application areas which should always be displayed, an application status pane, an application button group, an application menu bar, an application title band and an application tool bar.
Importantly, 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).
Return value
TRect
The area of the screen available to the application for drawing.
从Description我们可以看到:ClientRect()获得应用程序绘制的有效屏幕区域,但是这个区域不包括那些总是显示的非应用程序区域,比如:应用程序状态面板(application status pane)、按钮(button group)、应用程序的菜单bar、标题、工具条。
而且更重要的是从下面一行可以看出,这个ClientRect()所获得区域的top-left坐标是(0,45)。
通过上面的分析我们知道,UI在构造我们的Container时传递一个所谓的"客户矩形区域",这个"客户矩形区域"的top-left坐标是(0,45),从而也就知道如果要让我们的程序全屏显示,那么我们需要改变的是构造Container的时候传递的矩形大小。
那么就有如下几种方法:
①如果我们知道屏幕尺寸,那么就可以把iAppContainer->ConstructL( );里面的参数改为TRect (0,0,176,208)。
②上面的程序不具有适配性,因为我们把屏幕的宽度和高度写死了。
我们来看Symbian给我们提供的一个方法
ApplicationRect()
TRect ApplicationRect() const;
Description
Gets the total area of the screen available to the application. This includes the space that is available for a toolbar, toolband or title band, if the application requires them.
Return value
TRect
The total area of the screen available to the application.