Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 07:52, 14 June 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

From Wiki
Jump to: navigation, search

Archived.pngArchived: 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
Platform(s): S60 3rd Edition, FP2
S60 3rd Edition FP2
Created: User:Technical writer 1 (04 Apr 2008)
Last edited: hamishwillee (14 Jun 2012)


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 )
aBtGrC->SetRect( aBtGrC->Rect() );

Using SetCbaImage():

_LIT(KCBAImageMBMFilename, "c:\\data\\images\\testimage.mbm");
TFileName mbmFile(KCBAImageMBMFilename);
cba = CEikButtonGroupContainer::Current();
image = new (ELeave) CEikImage;
CleanupStack::PushL( image );
image->CreatePictureFromFileL( mbmFile, EMbmEnumLSKImage );
CleanupStack::Pop( image );
// Set image for LSK (ETrue as 3rd parameter)
// Transfers ownership of image - do not delete yourself
SetCbaImage( cba, *image, ETrue );
This page was last modified on 14 June 2012, at 07:52.
57 page views in the last 30 days.