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
This snippet demonstrates how to retrieve the screen resolution of S60 3rd and later devices. This snippet can be self-signed.
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.
//necessary header file
//displayXPixels contains X of screen resolution
//retrieve EDisplayXPixels value of this phone
HAL::Get( HALData::EDisplayXPixels, displayXPixels );
//displayYPixelscontains Y of screen resolution
//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.