×
Namespaces

Variants
Actions

为功能键设置图片

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

测试基于
设备:: Nokia N96, Nokia N78

兼容于
平台: S60 3rd Edition FP2
S60 3rd Edition FP2

文章
翻译:
hoolee
最后由 hamishwillee 在 07 Aug 2012 编辑
  • 详细描述

Command Button Array(CBA)在S60手机屏幕的下方(在竖屏模式下)。下列代码片段演示了如何设置为左右功能键设置图片。

#include <eikbtgpc.h>
#include <eikcba.h> // link against avkon.lib, eikcoctl.lib
 
void SetCbaImage( CEikButtonGroupContainer* aBtGrC,
CEikImage& aImage,
TBool aLSK )
{
TInt cmdPos = aLSK ? 0 : 2;
TInt cmdId = aBtGrC->ButtonGroup()->CommandId( cmdPos );
CEikCbaButton* button =
(CEikCbaButton*)aBtGrC->ControlOrNull( cmdId );
if( button )
{
button->SetImage(aImage);
aBtGrC->SetRect( aBtGrC->Rect() );
aBtGrC->DrawNow();
}
}

使用SetCbaImage()

_LIT(KCBAImageMBMFilename, "c:\\data\\images\\testimage.mbm");
TFileName mbmFile(KCBAImageMBMFilename);
 
cba = CEikButtonGroupContainer::Current();
if(cba)
{
image = new (ELeave) CEikImage;
CleanupStack::PushL( image );
image->CreatePictureFromFileL( mbmFile, EMbmEnumLSKImage );
image->SetBrushStyle(CGraphicsContext::ESolidBrush);
CleanupStack::Pop( image );
 
// Set image for LSK (ETrue as 3rd parameter)
// Transfers ownership of image - do not delete yourself
SetCbaImage( cba, *image, ETrue );
image->DrawNow();
}
This page was last modified on 7 August 2012, at 03:17.
79 page views in the last 30 days.
×