编辑框 等

 

修改CEikEDWin字体颜色

 //set color
 CCharFormatLayer* FormatLayer = CEikonEnv::NewDefaultCharFormatLayerL();
 TCharFormat charFormat;
 TCharFormatMask charFormatMask;
 FormatLayer->Sense(charFormat, charFormatMask);
 charFormat.iFontPresentation.iTextColor=TRgb( 255,255,255 );
 charFormatMask.SetAttrib(EAttColor);
 FormatLayer->SetL(charFormat, charFormatMask);
 m_pEdwin->SetCharFormatLayer(FormatLayer);  // Edwin takes the ownership
 
为CEikEdwin绘制标准边框
void CAppView::ConstructL(const TRect& aRect)
{
// ...
 
// Set border type
iEditor->SetBorder(TGulBorder::ESingleDotted);
 
// ...
}
void CAppView::Draw(const TRect& aRect) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
 
// Clear the screen
gc.Clear(aRect);
 
// Get the border
TGulBorder border = iEditor->Border();
 
// Draw the border so that it surrounds iEditor
TRect editorRect = iEditor->Rect();
border.Draw(gc, border.OuterRect(editorRect));
}

通过MEikEdwinObserver监控CEikEdwin

From: http://blog.csdn.net/Beover1984/archive/2007/09/13/1783694.aspx

CEikEdwin提供了SetEdwinObserver()和 AddEdwinObserverL()方法用来设置和添加标准编辑框CEikEdwin的观察器,通过派生并实现MEikEdwinObserver中的纯虚函数HandleEdwinEventL()就可以获得编辑框的一些标准事件,下面的代码展示了具体的实现方法:

// INCLUDES
#include <coecntrl.h>
#include <eikedwob.h> //for MEikEdwinObserver

// CLASS DECLARATION

/**
*  CEdwinContainer control class.
*  
*/
class CEdwinContainer: public CCoeControl, public MEikEdwinObserver
{
public:
...............
 // Functions from MEikEdwinObserver
 void HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType);
private:
 CEikEdwin *iEdwin;
}

void CEdwinContainer::ConstructL(const TRect& aRect)
{
 iEdwin = new (ELeave) CEikEdwin;
 iEdwin->SetContainerWindowL(*this);
 iEdwin->ConstructL( EAknEditorFlagDefault, 15, 15, 1 );
 iEdwin->SetEdwinObserverL( this );
 iEdwin->SetFocus( ETrue );
}

void CEdwinContainer::HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType)
{
 switch( aEventType )
 {
 case EEventFormatChanged:    //Unknown
  break;

 case EEventTextUpdate:     //编辑框的内容发生变化
  break;

 case EEventNavigation:    //光标位置发生改变
  break;
 }
}

另外,在有些SDK的文档上没有给出EEventTextUpdate枚举值,却说明EEventFormatChanged对应的事件是编辑框的内容发生变化,这使我在开发时浪费了不少时间,最后直接看它的头文件才恍然大悟.

——————————————————————————————————————————————

 

修改密码编辑框颜色

iSecret1->OverrideColorL(EColorControlText, textColor3);

 

————————————————————————————————————————————

修改Label字体颜色

iLabel2->OverrideColorL(EColorLabelTextEmphasis, textColor3);

iLabel2->SetEmphasis(CEikLabel::EPartialEmphasis);

iLabel2->SetBrushStyle(CWindowGc::ENullBrush);

 

你可能感兴趣的:(Class,文档,border)