Symbian S60为功能键设置图片
开发伙伴平台:
S60 3rd Edition, FP2
详细描述
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();
}