Namespaces
Variants
Actions

Archived:Setting an image for a softkey using Symbian C++

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata

Tested with
Devices(s): Nokia N96, Nokia N78

Compatibility
Platform(s): S60 3rd Edition, FP2

Article
Created: User:Technical writer 1 (04 Apr 2008)
Last edited: hamishwillee (14 Jun 2012)

Description

The Command Button Array (CBA) is located at the bottom of the screen in S60 devices (in portrait mode). The following code snippet demonstrates how to set an image for the left and right softkeys.

#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();
}
}

Using 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 14 June 2012, at 10:52.
129 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved