| ID | Creation date | October 17, 2008 | |
| Platform | S60 3rd Edition, S60 5th Edition | Tested on devices | Nokia E90 |
| Category | Symbian C++ | Subcategory | UI |
| Keywords (APIs, classes, methods, functions): CAknAppUiBase::Orientation(), TAppUiOrientation, CCoeEnv. |
This snippet shows how to get current orientation by using CAknAppUiBase::Orientation(). 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.
Here we assume that we already have a working GUI based application.
The following capabilities and libraries are required:
CAPABILITY None
LIBRARY avkon.lib
Source:
#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();
}
}
Successful execution of the above code gets the current orientation value.