参考资料:http://www.devdiv.net/viewthread.php?tid=2667&highlight=Grid

步骤:

1、*Ui.cpp源文件

在构造函数ConstructL()中:

BaseConstructL(EAknEnableSkin),让程序支持皮肤功能。

2、 MMP文件

如何用自己的图片作程序背景START BITMAP bg.mbm
如何用自己的图片作程序背景    HEADER
如何用自己的图片作程序背景     SOURCEPATH ..icons
如何用自己的图片作程序背景     SOURCE c12     bg.bmp
如何用自己的图片作程序背景END

在项目的文件目录下新建一个icons文件夹,里面添加想要的背景图片,这里是bg.bmp;

当然,这个可以自己定制。

3、Container.h头文件

如何用自己的图片作程序背景// FORWARD DECLARATION
如何用自己的图片作程序背景
class CAknsBasicBackgroundControlContext;

该类的头文件:AknsBasicBackgroundControlContext.h

库:AknSkins.lib

添加成员变量:

如何用自己的图片作程序背景CAknsBasicBackgroundControlContext* iBackGround;

4、Container.cpp源文件

添加头文件:

如何用自己的图片作程序背景#include <AknsBasicBackgroundControlContext.h> //for CAknsBasicBackgroundControlContext
如何用自己的图片作程序背景
#include <AknsDrawUtils.h> //for AknsDrawUtils, CAknsItemDef and MAknskinInstance
如何用自己的图片作程序背景
#include <AknUtils.h> //for CompeleteWithAppPath()
如何用自己的图片作程序背景
#include <bg.mbg> //Background file

ConstructL()中添加:

如何用自己的图片作程序背景iBackGround = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, Rect(), EFalse );
如何用自己的图片作程序背景MAknsSkinInstance
* skin = AknsUtils::SkinInstance();
如何用自己的图片作程序背景_LIT(KBitmapPath,
"bg.mbm");
如何用自己的图片作程序背景TFileName bitmapFile (KBitmapPath);
如何用自己的图片作程序背景User::LeaveIfError(CompleteWithAppPath(bitmapFile));
如何用自己的图片作程序背景CAknsItemDef
* mainBgItemDef = AknsUtils::CreateBitmapItemDefL(KAknsIIDQsnBgAreaMain,bitmapFile,EMbmBgBg);
如何用自己的图片作程序背景skin
->SetLocalItemDefL( mainBgItemDef );

SizeChanged()中添加:

如何用自己的图片作程序背景    if ( iBackGround )
        }

Draw() 中添加:

如何用自己的图片作程序背景MAknsSkinInstance* skin = AknsUtils::SkinInstance();
如何用自己的图片作程序背景MAknsControlContext
* cc = AknsDrawUtils::ControlContext( this );
如何用自己的图片作程序背景AknsDrawUtils::Background( skin, cc, 
this, gc, aRect );

添加成员函数:

如何用自己的图片作程序背景TTypeUid::Ptr CModel2ndContainer::MopSupplyObject(TTypeUid aId)
    }

别忘了先在头文件中声明,这个函数不知道在哪里被调用,但是必须要有。

析构函数添加:

如何用自己的图片作程序背景delete iBackGround;

 

这样,程序编译、运行后应该就能看见自定义的背景了,HF!:)

相关文章:

  • 2021-07-02
  • 2021-05-14
  • 2021-05-03
  • 2021-05-08
  • 2021-08-06
  • 2022-01-05
  • 2021-10-20
  • 2021-09-19
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2021-12-27
  • 2021-09-25
  • 2021-04-17
相关资源
相似解决方案