編輯框 等

來源:互聯網
上載者:User

 

修改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監控CEikEdwinFrom: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);

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.