Namespaces
Variants
Actions

Archived:How to use custom background for listbox using Symbian C++

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata

Code Example
Tested with
Devices(s): S60 Emulator

Compatibility
Platform(s): Symbian

Article
Keywords: KAknsIIDQsnBgAreaMainListGene, MAknsSkinInstance, AknsUtils, SkinInstance, CAknsItemData, GetCachedItemData, EAknsITMaskedBitmap, CreateMaskedBitmapItemDefL, CreateBitmapItemDefL
Created: chenziteng (07 Oct 2009)
Last edited: hamishwillee (01 Jul 2012)


Overview

On S60 3rd Edition the list-box is fully skinned, and the list-box background is actually an image identified by an ID KAknsIIDQsnBgAreaMainListGene. You can find the definition of the IDs in the system header file AknsConstants.h.

The following code shows how to override the skin image for list-box background by a self-created bitmap.

void CTdjgmcqeListBox::ConstructL( 
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
...
_LIT(KMbmFile, "z:\\resource\\apps\\Tdjgmcqe.mbm");
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
CAknsItemData* item = skin->GetCachedItemData(KAknsIIDQsnBgAreaMainListGene);
if(item==NULL)
{
item = skin->CreateUncachedItemDataL(KAknsIIDQsnBgAreaMainListGene);
}
if(item->Type()==EAknsITMaskedBitmap)
{
CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnBgAreaMainListGene, KMbmFile, EMbmTdjgmcqeMainarea, EMbmTdjgmcqeMainareamask);
skin->SetLocalItemDefL(def);
}
else
{
CAknsItemDef* def = AknsUtils::CreateBitmapItemDefL(KAknsIIDQsnBgAreaMainListGene, KMbmFile, EMbmTdjgmcqeMainarea);
skin->SetLocalItemDefL(def);
}
...
}

Source Code

Full example (you should change the hard-coded mbm path in order to run it on target):

Tdjgmcqe(ListBoxCustomBackground).zip

Screenshot (first: normal listbox, second: listbox with custom background):

Tdjgmcqe(NormalListBox).PNGTdjgmcqe(ListBoxCustomBackground).PNG

Relative documents

Archived:How to change the highlighted listbox item background using Symbian C++

How to use custom background for text editors

This page was last modified on 1 July 2012, at 13:27.
131 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved