Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 12:07, 18 June 2009 by copyeditor (Talk | contribs)

Listening for screen orientation changes in Symbian C++

From Wiki
Jump to: navigation, search

Template:KBCS

Article Metadata
Tested with
Devices(s): Nokia N95
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Article
Keywords: CAknAppUi::HandleResourceChangeL(), CCoeControl::HandleResourceChange()
Created: (18 Jun 2009)
Last edited: copyeditor (18 Jun 2009)

Contents

Overview

Layout and screen orientation change events are generated when the screen size or layout is changed. The S60 platform supports multiple screen resolutions. Handling this event can be implemented into application CAknAppUi class or application CCoeControl UI controls.


Source

Solution 1: UI control derived from CCoeControl can handle layout changes overriding the CCoeControl::HandleResourceChange() method

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);
}
}

Solution 2: Application UI class derived from CAknAppUi can override CEikAppUi::HandleResourceChangeL() to get the KEikDynamicLayoutVariantSwitch layout change event.

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 );
}


See also

TSS001178 - Switching orientation in dialog-based applications


Postconditions

A layout change event is received and the new layout size is read.

82 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.

×