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.

How to get the current screen orientation using Symbian C++

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia E90
CompatibilityPlatform Security
Signing Required: Self-Signed
Capabilities: None
Keywords: CAknAppUiBase::Orientation(), TAppUiOrientation, CCoeEnv.
Created: vasant21 (17 Oct 2008)
Last edited: hamishwillee (30 May 2013)


This article shows how to get the current screen orientation using Symbian C++

Using screen dimensions

Below is a reliable way to query the screen dimensions, and hence determine orientation, using Symbian C++.

CWsScreenDevice* screenDevice = CEikonEnv::Static()->ScreenDevice();
const TSize& screenSize = screenDevice->SizeInPixels();
if (screenSize.iWidth > screenSize.iHeight)
// LayoutLandscape;
// LayoutPortrait;

Using CAknAppUiBase::Orientation()

This snippet below shows how to get current orientation by using CAknAppUiBase::Orientation().

Warning.pngWarning: Note that the value returned is simply the value that the app itself defines using SetOrientation() - and will return EAppUiOrientationUnspecified if not set.

You cannot call CAknAppUiBase::Orientation() directly in a class which is not derived directly or indirectly from CAknAppUiBase or if you do not have access to AppUi instance, then you can also fetch the information using CCoeEnv.

This snippet can be self-signed and we assume that we already have a working GUI based application.

The following capabilities and libraries are required:

LIBRARY avkon.lib


#include <aknappui.h>
CCoeEnv* env = CCoeEnv::Static();
if( env )
CAknAppUiBase* appUiBase = REINTERPRET_CAST( CAknAppUiBase*, env->AppUi() );
if( appUiBase )
* Possible values for TAppUiOrientation are :
* EAppUiOrientationUnspecified,
* EAppUiOrientationPortrait,
* EAppUiOrientationLandscape,
* EAppUiOrientationAutomatic

CAknAppUiBase::TAppUiOrientation orientation = appUiBase->Orientation();
This page was last modified on 30 May 2013, at 02:54.
110 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.