Namespaces

Variants
Actions

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 over the next few weeks. Thanks for all your past and future contributions.

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
Compatibility
Platform(s): S60 3rd Edition, FP2
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 07:52.
73 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×