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.

How to Change CEikLabel Color in Symbian C++

From Wiki
Jump to: navigation, search

This code snippet shows how to change the CEikLabel text and background colour.

Article Metadata
CompatibilityPlatform Security
Signing Required: Self-Signed
Capabilities: None
Article
Created: User:Kanu123 (29 Jun 2007)
Last edited: hamishwillee (12 Oct 2012)
#include <gulcolor.h>
....
 
//Here iLabel is a class member of type CEikLabel*
iLabel= new (ELeave) CEikLabel;
iLabel->SetContainerWindowL( *this );
iLabel->SetTextL( _L("Some Text") );
 
// Using blue as foreground color
iLabel->OverrideColorL( EColorLabelText, KRgbBlue );
 
// Set red as background color
iLabel->OverrideColorL(EColorControlBackground, KRgbRed )

S60 3rd Edition

As discussed in this discussion thread, EColorControlBackground doesn't work for setting the background on the S60 3rd Edition emulator. Instead you can use EColorLabelHighlightFullEmphasis as shown below:

...
iLabel->SetEmphasis( CEikLabel::EFullEmphasis);
iLabel->OverrideColorL( EColorLabelHighlightFullEmphasis, KRgbRed ); // red background
iLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbBlue ); // and blue text
...
This page was last modified on 12 October 2012, at 04:07.
88 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.

×