首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Symbian >

麻烦高手帮小弟我解决一下listbox不显示的有关问题

2012-04-07 
麻烦高手帮我解决一下listbox不显示的问题/* Copyright (c) 2008, Nokia. All rights reserved */#include

麻烦高手帮我解决一下listbox不显示的问题
/* Copyright (c) 2008, Nokia. All rights reserved */

#include "SkyDoucmentAppView5.h"
#include <eikenv.h>
#include <Skydoucment.rsg>
#include <gdi.h>
#include <e32std.h>
#include <avkon.hrh>
#include <aknutils.h>
#include <aknlists.h> 
#include <barsread.h> 
CSkydoucmentAppView5* CSkydoucmentAppView5::NewL(const TRect& aRect)
  {
CSkydoucmentAppView5* self = NewLC(aRect);
CleanupStack::Pop(self);
return self;
  }

CSkydoucmentAppView5* CSkydoucmentAppView5::NewLC(const TRect& aRect)
  {
CSkydoucmentAppView5* self = new (ELeave) CSkydoucmentAppView5;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
  }

void CSkydoucmentAppView5::ConstructL(const TRect& aRect)
  {
CreateWindowL();
CEikColumnListBox* iColListBox;
iColListBox = new (ELeave) CAknSingleStyleListBox();
iColListBox->SetContainerWindowL( *this );
//从资源文件中生成LISTBOX
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC( reader, R_TEXT_SINGLE);
iColListBox->ConstructFromResourceL( reader );
//设置SCROLLBAR
iColListBox->CreateScrollBarFrameL( ETrue );
iColListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
//适合窗口大小
iColListBox->SetRect(Rect());
//激活
iColListBox->ActivateL();
CleanupStack::PopAndDestroy(); 
SetRect(aRect);
ActivateL();
  }

CSkydoucmentAppView5::CSkydoucmentAppView5()
  {
  // Add any construction code that can not leave here
  }


CSkydoucmentAppView5::~CSkydoucmentAppView5()
  {
  // Add any destruction code here
  }

void CSkydoucmentAppView5::Draw(const TRect& /*aRect*/) const
  {
// Get the standard graphics context 
CWindowGc& gc = SystemGc();
// Gets the control's extent
gc.Clear(Rect());
  }
在窗口中不显示listbox


RESOURCE LISTBOX r_text_single
{
array_id = r_array_single;
flags = EAknListBoxSelectionList;
}
RESOURCE ARRAY r_array_single
{
items = 
{
LBUF
{
txt = " \taaaaaa";
}
};
}




[解决办法]
你的CSkydoucmentAppView5从什么继承的?一般情况下建议将控件放在Continer里,并要注意如下小例中的两个函数:
TInt CContainerContainer::CountComponentControls() const

{

return 1; // return number of controls inside this container 

// (i.e. the list)

}

and

CCoeControl* CContainerContainer::ComponentControl(TInt aIndex) const

{

switch ( aIndex )

{

case 0:

return iListBox; // return a pointer to the listbox

default:

return NULL;

}

}

热点排行