×
Namespaces

Variants
Actions

监听屏幕布局的变化

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台: S60 3rd Edition, S60 5th Edition

文章
翻译:
hoolee
最后由 hamishwillee 在 30 May 2013 编辑


  • 详细描述

当屏幕的尺寸或方位发生变化时,系统就会产生布局和屏幕方位改变的事件。S60平台支持多个屏幕分辨率,这个事件可以通过程序的CAknAppUi类或程序的CCoeControl控件处理。

  • 源代码

解决方案1:

派生自CCoeControl的控件可以通过重载CCoeControl::HandleResourceChange()方法来获取布局的改变通知:

void CExampleControl::HandleResourceChange(TInt aType)
{
// Call base class implementation
CCoeControl::HandleResourceChange(aType);
if ( aType==KEikDynamicLayoutVariantSwitch )
{
TRect rect;
// Ask where container's rectangle should be
// EMainPane equals to area returned by
// CEikAppUi::ClientRect()
AknLayoutUtils::LayoutMetricsRect(
AknLayoutUtils::EMainPane,rect);
// Set new screen rect
SetRect(rect);
}
}

解决方案2:

从CAknAppUi派生的Application UI类可以重载CEikAppUi::HandleResourceChangeL()方法,以便获得KEikDynamicLayoutVariantSwitch的布局改变通知

void CExampleAppUi::HandleResourceChangeL(TInt aType)
{
// Call base class implementation
CAknAppUi::HandleResourceChangeL( aType );
if ( aType == KEikDynamicLayoutVariantSwitch )
{
TRect rect;
// Ask where container's rectangle should be
// EMainPane equals to area returned by
// CEikAppUi::ClientRect()
AknLayoutUtils::LayoutMetricsRect(
AknLayoutUtils::EMainPane,rect);
 
// Set new screen rect
// Must not call this if the iExampleControlContainer
// component is on the control stack
iExampleControlContainer->SetRect(rect);
}
 
// Must not call this if the iSomeDialog
// component is on the control stack
//iSomeDialog->HandleResourceChangeL( aType );
}


  • 相关资料

Archived:Switching orientation in dialog-based Symbian C++ applications

This page was last modified on 30 May 2013, at 07:37.
88 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×