Archived:How to use custom background for listbox using Symbian C++
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
Source file: Media:Tdjgmcqe(ListBoxCustomBackground).zip
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):
Relative documents
Archived:How to change the highlighted listbox item background using Symbian C++


This code dosen`t work for s60 3d edition MR... ( Any ideas?
AKNSKINS: (Error) "RAknsSrvSession::ClientError"
Hamishwillee - Error is -6 bad request
I'm guessing that for some reason KAknsIIDQsnBgAreaMainListGene is an invalid value to pass. Is this the example code File:Tdjgmcqe(ListBoxCustomBackground).zip?
I suggest you raise this on the Symbian C++ forums. If you get an answer, please post a comment back here.hamishwillee 00:32, 7 December 2011 (EET)
Samooha 2020 - 3rd MR problem with ! as drive letter in skin APIs
Make sure the MIF or MBM file path contains drive letter not ! in other words this format doesn't acceptable on 3rd MR "!:\\resource\\apps\\Tdjgmcqe.mbm" you have to use the below 1. "c:\\resource\\apps\\Tdjgmcqe.mbm"
2. OR "e:\\resource\\apps\\Tdjgmcqe.mbm"samooha_2020 10:10, 8 November 2012 (EET)