首 页 | 新 闻 | Symbian | Windows Mobile| J2ME | 下载中心 | 游戏策划 | 购书指南 | 移动开发视频教程
您现在的位置: 开发视界 >> Symbian英文资料 >> Graphics >> 文章正文
How to change the color of a CEikLabel
作者:佚名    文章来源:不详    更新时间:2006-5-7 11:14:29

A CEikLabel is a basic component use to display static text in a control. It is fairly easy and straightforward to use as soon as you don’t have to change its color: there is no SetColor() primitive.

If you are reading this page, you are probably looking for the answer. And as usual in the Symbian world, it is pretty trivial once you know how to do it. As a matter of fact, you have to override the EColorLabelTextEmphasis setting of your label using the OverrideColorL() primitive and then to activate the setting, using SetEmphasis(). The code below shows how to do this:

#include <gulcolor.h>
...
// Basic Label Construction
CEikLabel* myLabel;
myLabel= new (ELeave) CEikLabel;
myLabel->SetContainerWindowL( *this );
myLabel->SetTextL( _L("NewLC rulez!") );

// Now Set the foreground color to Red
myLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbRed );
myLabel->SetEmphasis( CEikLabel::EPartialEmphasis );  

Alternatively you may want to specify a foreground AND a background color. In this case, you also have to override and activate the EColorLabelHighlightFullEmphasis setting:

// Now Set the foreground Color to White
// and the background color to Red
myLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbWhite );
myLabel->OverrideColorL( EColorLabelHighlightFullEmphasis, KRgbRed );
myLabel->SetEmphasis( CEikLabel::EFullEmphasis );  
相关文章:
Integrating LeaveScan into Codewarrior 3.x