首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 软件时空 > 软件相关 > Symbian Dynamic ListBox
【标  题】:Symbian Dynamic ListBox
【关键字】:Symbian,Dynamic,ListBox
【来  源】:http://blog.csdn.net/zhaotaobenny/archive/2006/11/12/1380198.aspx

Symbian Dynamic ListBox

关于Symbian 动态列表的构建

 

 

1.MMP文件中需要的库:
LIBRARY euser.lib apparc.lib cone.lib eikcore.lib
LIBRARY eikcoctl.lib avkon.lib eikctl.lib bafl.lib
2.在资源文件中定义ListBox 资源:
   RESOURCE LISTBOX r_notebook_listbox
       {
       flags = EAknListBoxSelectionList | EAknListBoxLoopScrolling;
       }
 
3.定义拥有ListBox的控件类,使其从CCoeControl,MEikListBoxObserver 公有继承,并在类中定义ListBox为数据成员:
   #include <aknlists.h> // CAknSingleStyleListBox
#include <barsread.h> // TResource Reader
#include <e32def.h> // STATIC_CAST
#include <eikclbd.h> // CColumnListBoxData
#include <eikmenub.h> // CEikMenuBarclass
#include <stringloader.h> // StringLoader
#include <uikon.hrh> // TKeyCode #defines
 
CContainer : public CCoeControl, MEikListBoxObserver
{
// Other Code
private:
        CAknColumnListBox*  iList;  
}
CAknColumnListBox ListBox的基类。
 
4.建立列表:
  void CreateListL()
{
       iList = new (ELeave) CAknSingleStyleListBox;
       iList->SetContainerWindowL(*this);
      
       TResourceReader reader;
        CEikonEnv::Static()->CreateResourceReaderLC(reader, R_NOTEBOOK_LISTBOX);
        iList->ConstructFromResourceL(reader);
       CleanupStack::PopAndDestroy();
}
 
5.加载列表项:
   void SetupListItemsL()
{
       CTextListBoxModel* model = iList->Model();
       model->SetOwnershipType (ELbmOwnsItemArray);
     CDesCArray* savedArray = STATIC_CAST(CDesCArray*, model->
ItemTextArray());
       LoadSavedL(*savedArray);
}
 
void LoadSavedL(CDesCArray& aArray)
{
   _LIT (KString,"\tSelect%d");
   TBuf <16> aString;
   for (TInt i = 1; i< 10; i++)
          {
          aString.Format(KString(),i);
          aArray.AppendL (aString);
          }
}
首先取得列表的模型,获取模型中的列表项数组,将列表项逐个添加到列表项数组里。
 
6.设置滚动条:
   void SetupScrollBarsL()
{
       iList->CreateScrollBarFrameL();
       iList->ScrollBarFrame()->SetScrollBarVisibilityL(
              CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
}
 
7.其他控件属性或函数的设置:
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
       if (iList)
              return iList->OfferKeyEventL (aKeyEvent, aType);
       else
              return EKeyWasNotConsumed;
}
 
void SizeChanged()
    {
    iList->SetExtent( TPoint(0,0), iList->MinimumSize() );
    }
 
void Draw(const TRect& aRect) const
    {
     CWindowGc& gc = SystemGc();
       gc.Clear(aRect);
    }
 

 

微型16/32位嵌入式GUI-技术特色:【上一篇】
微型16/32位嵌入式GUI:【下一篇】
【相关文章】
  • [Symbian项目进展]实现了Tab页
  • [Symbian项目进展]完成了规则库的增删改的功能
  • Spiderman’s workout (dynamic programming)
  • DLL(Dynamic Link Libraries)专题
  • dynamic static cast
  • Dynamic Proxy模式初体验
  • 我对设计模式的理解:AOP vs 动态代理(Dynamic Proxy)
  • 使用Carbide.vs与VS.NET2003构建Symbian开发平台(s60)
  • Symbian 上使用BSD socket 进行raw socket编程
  • Tips:给ListBox绑定数据源
  • 【随机文章】
  • 程序员的10种级别
  • WAP Push SP接口协议
  • [新一代互联网有望快6000倍]z
  • 基于TinyX的第一个程序
  • Linux Kernel Netfilter Ipt_recent拒绝服务漏洞
  • 常备JS操作
  • Oracle 中通过ROWNUM来实现分页查询
  • gcc, 常用选项
  • 简单IP路由
  • 《水墨情》笔刷深度挖掘
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.