//支持皮肤需要这两个头文件 container里面加
#include
#include
//UI构造函数CONSTRUCTL里面实现,默认已经有了
BaseConstructL( EAknEnableSkin );
//container头文件里面定义
CAknsBasicBackgroundControlContext *iBgContext;
//constructL函数里面实现
iBgContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain, aRect, ETrue);
//使用当前皮肤来绘制背景 Draw函数实现
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
//MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );
//加载系统皮肤需要用到的函数
TTypeUid::Ptr CEagleEyeMainContainer::MopSupplyObject(TTypeUid aId)
{
if (iBgContext )
{
return MAknsControlContext::SupplyMopObject( aId, iBgContext );
}
return CCoeControl::MopSupplyObject(aId);
}
//MMP文件中需在加入LIB库
LIBRARY aknskins.lib aknskinsrv.lib aknswallpaperutils.lib
//上面的语句加上就可以实现加载系统皮肤,但是DrawNow时会出现闪屏,消除闪屏还需要加入如下代码,先把皮肤加载到CFBSBITMAP类型的变量中.
//CONSTRUCTL
offScreenBitmap = new (ELeave) CFbsBitmap();
User::LeaveIfError( offScreenBitmap->Create( aRect.Size(), EColor4K ) );
bitmapDevice = CFbsBitmapDevice::NewL( offScreenBitmap );
User::LeaveIfError( bitmapDevice->CreateContext( bitGc ) );
AknsDrawUtils::DrawBackground( AknsUtils::SkinInstance(),
iBgContext,this,*bitGc,TPoint(0,0),aRect,
KAknsDrawParamDefault );
//DRAW,把前面绘制背景的语句去掉,换成下面的语句
gc.BitBlt( Rect().iTl,offScreenBitmap );
//上面的操作完成后有可能窗口区有可能会不满屏,应该是CONSTRUCTL里面的SET(RECT)函数的位置问题.
加载系统皮肤
最新推荐文章于 2024-11-23 10:16:36 发布