我按照《遨游symbian-手机应用入门》这本书写了最个最简单的listbox但是运行的时候出现KERN-EXEC 3错误,代码如下,高手帮忙看看:[code=C/C++][/code]
CTestAppView* CTestAppView::NewL(const TRect& aRect)
{
CTestAppView* self = CTestAppView::NewLC(aRect);
CleanupStack::Pop();//self
return self;
}
CTestAppView* CTestAppView::NewLC(const TRect& aRect)
{
CTestAppView* self = new (ELeave) CTestAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
void CTestAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
// Activate the window, which makes it ready to be drawn
ActivateL();
iListBox = new (ELeave) CAknSingleStyleListBox;
iListBox->SetContainerWindowL(*this);
iListBox->SetListBoxObserver(this);
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC(reader, R_WEEK_LISTBOX);
iListBox->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy();
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EAuto);
}
CTestAppView::CTestAppView()
{
// No implementation required
}
CTestAppView::~CTestAppView()
{
// No implementation required
}
void CTestAppView::Draw(const TRect& /*aRect*/) const
{
CWindowGc& gc = SystemGc();
TRect drawRect(Rect());
gc.Clear(drawRect);
}
void CTestAppView::SizeChanged()
{
iListBox->SetRect(Rect());
DrawNow();
}
void CTestAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{
CCoeControl::HandlePointerEventL(aPointerEvent);
}
TInt CTestAppView::CountComponentControls() const
{
return 1;
}
CCoeControl * CTestAppView::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return iListBox;
break;
default:
return NULL;
break;
}
return NULL;
}
void CTestAppView::HandleListBoxEventL(CEikListBox* aListBox,
TListBoxEvent aEventType)
{
}
------解决方案--------------------------------------------------------
// Activate the window, which makes it ready to be drawn
ActivateL();
需要放到ConstructL()函数最后