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. Thanks for all your past and future contributions.

Enable Skin Support in Views/Containers

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Keywords: CAknsBasicBackgroundControlContext
Created: giridharn (25 May 2007)
Last edited: hamishwillee (22 Nov 2011)

You need to create a specific context to hold the skin bitmap for your control. Do this by adding the following data member to your view/container class:

CAknsBasicBackgroundControlContext* iBgContext;

And initialize properly in the corresponding ConstructL(), initialise a reference to the background bitmap:

#include <AknsDrawUtils.h>
#include <AknsBasicBackgroundControlContext.h>
void CYourAppView::ConstructL()
iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,aRect,ETrue);

Call the corresponding destructor.

void CYourAppView::~CYourAppView()
delete iBgContext;

This context shall be passed to the child controls so that they can redisplay themselves correctly. This is done throgh MOP relationship and you then need to override the MopSupplyObject() primitive as follow:

TTypeUid::Ptr CYourAppView::MopSupplyObject(TTypeUid aId)
if (iBgContext )
return MAknsControlContext::SupplyMopObject( aId, iBgContext );
return CCoeControl::MopSupplyObject(aId);

Each control Draw primitive shall now be updated to display the skin as background:

// Draw this application's view to the screen
void CYourAppView::Draw(const TRect& aRect) const
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Redraw the background using the default skin
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
AknsDrawUtils::Background( skin, cc, this, gc, aRect );
void CYourAppView::SizeChanged()
if ( &Window() )
iBgContext->SetParentPos( PositionRelativeToScreen() );

If your control contains a listbox, you can enable skin behind the items by calling:


Link against.

LIBRARY aknskins.lib aknskinsrv.lib

Full example

File:Otoncyvg(EdwinVerticalAlign).zip Tested on S60 3rd Edition FP2 emulator.

S60ThemeDefault.PNG S60ThemeJingmask.PNG

Other Related Links

This page was last modified on 22 November 2011, at 00:43.
43 page views in the last 30 days.