CEikEdWin 类的使用
CEikEdWin? 類的使用
CEikEdWin 是一個編輯框類,如同 edit,textbox ,這個類對應的 RESOURCE STRUCT 名為
EDWIN
把這個控件結構添加到資源文件中為
RESOURCE EDWIN r_edwin_test
{
????flags = EAknEditorFlagDefault;
??? width = qtn_app_edit_width;
??? lines = qtn_app_edit_height;
??? maxlength = qtn_app_edit_maxLength;
}
其中 qtn_app_edit_width/height/maxLength 是定義在 loc 文件中的
如:
#define qtn_app_edit_width? 50
#define qtn_app_edit_height 1
#define qtn_app_edit_maxLength 20
但是 EAknEditorFlagDefault 沒有找到在哪里定義,應該是默認設置
關于類在資源中的結構可以通過 Developer?Library?? API?Reference?? C++?API?reference?? Uikon?Resources 找到各個類的資源
結構定義
在 rss 文件中要引用 hrh 及 loc 文件
在代碼文件中要引入
工程名.rsg 文件
下面是添加一個 CEikEdwin 類的主要步驟:
#include "XXX.hrh"
#include "XXX.loc"
RESOURCE EDWIN r_edwin_Test
{
?flags = EAknEditorFlagDefault;
?width = qtn_app_edit_width;
?lines = qtn_app_edit_height;
?maxlength = qtn_app_edit_maxLength;
}
class CEikEdwin;
可以參考項目自動生成的代碼,都會有前向定義的
CEikEdwin* iEdit;
#include <barsread.h>??// for ResourceReader
#include <eikedwin.h>? // for CEikEdwin
#include <EDITCONTROL.RSG>? // 這個 rsg 文件是 rss 文件編譯生成的文件,對每個資源賦予一個 id
?TResourceReader aRead ;
?iCoeEnv->CreateResourceReaderLC(aRead,R_EDWIN_TEST);
?iEdit = new (ELeave) CEikEdwin();
?iEdit->SetContainerWindowL(*this);
?iEdit->ConstructFromResourceL(aRead);
?iEdit->SetBackgroundColorL(KRgbRed);
?//iEdit->SetTextL( _L("Add Your controls\n here"));
?CleanupStack::PopAndDestroy();
?iEdit->SetExtent(EDWIN_POS,iEdit->MinimumSize());? //?這句是指定位置的 edwin_pos 是 在頭文件中定義的 #define EDWIN_POS?????????? TPoint( 10, 25 )
?iEdit->SetFocus(ETrue);
實現代碼為:
TKeyResponse CeditTestContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType )
{
?if (iEdit)
?{
??if(iEdit->IsFocused())
??{
???return iEdit->OfferKeyEventL(aKeyEvent,aType);
??}
?}
}
===========================
zziss@原創(chuàng)
qi_jianzhou@126.com
?
?
?
轉載于:https://www.cnblogs.com/zziss/articles/1631041.html
總結
以上是生活随笔為你收集整理的CEikEdWin 类的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mx:button加skin光晕点击时,
- 下一篇: C#枚举硬件设备(升级版)