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 retrieve the screen resolution

From Wiki
Jump to: navigation, search

Article Metadata
Tested with
Devices(s): N78
Platform(s): S60 3rd,3rd FP1,3rd Fp2
Platform Security
Capabilities: )
Keywords: keywords=HAL::Get()
Created: lming (01 Nov 2008)
Last edited: hamishwillee (24 Jun 2011)


This snippet demonstrates how to retrieve the screen resolution of S60 3rd and later devices. This snippet can be self-signed.

Use case

screen resolution of S60 3rd and later devices can be 176x208,240x320,352x416 and 208x208(Nokia 5500). The application could detect the screen resolution, then adapting itself accordingly, for example, loading an optimized image for the device.

Source file

//necessary library
//necessary header file
#include <HAL.h>
#include <hal_data.h>
//displayXPixels contains X of screen resolution
TInt displayXPixels;
//retrieve EDisplayXPixels value of this phone
HAL::Get( HALData::EDisplayXPixels, displayXPixels );
//displayYPixelscontains Y of screen resolution
TInt displayYPixels;
//retrieve EDisplayYPixels value of this phone
HAL::Get( HALData::EDisplayYPixels, displayYPixels );

The HAL API, may or may not be supported on some devices, as there have been some instances reported, where the HAL has not worked.The following code snippets shows the calculation of Screen Resolution for S60 3rd edition(MR,FP1,FP2) & for S60 5th edition devices as well:

TInt WidthOfScreen = CEikonEnv::Static()->EikAppUi()->ApplicationRect().Width();
TInt heightOfScreen = CEikonEnv::Static()->EikAppUi()->ApplicationRect().Height();

CWsScreenDevice* screenDevice = CEikonEnv::Static()->ScreenDevice();
const TSize& screensize = screenDevice->SizeInPixels();
TInt WidthOfScreen = screensize.iWidth;
TInt heightOfScreen = screensize.iHeight;


The displayXPixels variable contains the screen width and the displayYPixels variable contains the screen height. On a N78, these values would be 240 and 320, respectively.

The WidthOfScreen variable is the width of screen & variable heightOfScreen is the height respectively, so for 5800ExpressMusic, these values would be 360 & 640 respectively.

This page was last modified on 24 June 2011, at 08:37.
58 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.