Link against aknskins.lib and include files
Add the libray named aknskins.lib in SkinSample.mmp
Code:
LIBRARY aknskins.lib // link against aknskins.lib
Add two include files in SkinExampleContainer.h
Code:
#include <AknsDrawUtils.h>// add this inlcude file skin
#include <AknsBasicBackgroundControlContext.h> //add this inlcude file skin
Enabling skins in AppUi
Code:
/* In SkinExampleAppUi.cpp */
void CSkinExampleAppUi::ConstructL()
{
BaseConstructL( EAknEnableSkin );//Construct a enalbe skin
.....
}
new and delete a MAknsControlContext class in Container class
Add a MAknsControlContext class in container class
Code:
/* In skinExampleContainer.h */
class CSkinExampleContainer : public CCoeControl, MCoeControlObserver
{
....
private:
MAknsControlContext* iBackGround; // for skins support
}
/* In SkinExapleContainer.cpp */
void CSkinExampleContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
Draw the background bitmap using Skin library
Code:
/* In SkinExapleContainer.cpp */
void CSkinExampleContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// draw background
MAknsSkinInstance* skin = AknsUtils::SkinInstance();//new
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );//new
AknsDrawUtils::Background( skin, cc, this, gc, aRect );//new
}
MObjectProvider Chains
MObjectProvider interface can be used to make object instances available to child controls.
MopSupplyObject returns a pointer based on the given UID.