求助:Column ListBox 中加入图片
写了个代码在CEikColumnListBox中加入一列图片。
---------------------------
iListBx = new (ELeave) CEikColumnListBox;
iListBx->ConstructL(this,CEikListBox::ENoExtendedSelection);
iListBx->SetItemHeightL(25);
iListBx->SetContainerWindowL(*this);
iListBx->SetListBoxObserver(this);
TPoint* pos = new TPoint(0,0);
TSize* siz = new TSize(aRect.Width() - 10,aRect.Height() - 10);
iListBx->SetExtent(*pos, *siz);
iListBx->SetBorder(TGulBorder::ENone);
iListBx->ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0,25);
iListBx->ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1,180);
iListBx->ItemDrawer()->ColumnData()->SetGraphicsColumnL(0,ETrue);
iListBx->ItemDrawer()->ColumnData()->SetGraphicsColumnL(1,EFalse);
CArrayPtr<CGulIcon>* icons = (CArrayPtr<CGulIcon>*) new (ELeave) CArrayPtrFlat<CGulIcon>(2);
_LIT(KIconPath1,"Z:\\SYSTEM\\APPS\\Study\\1.mbm");
_LIT(KIconPath2,"Z:\\SYSTEM\\APPS\\Study\\2.mbm");
TBufC16<100> iconPath1 (KIconPath1);
TBufC16<100> iconPath2 (KIconPath2);
icons->AppendL(iEikonEnv->CreateIconL(iconPath1,0,1));
icons->AppendL(iEikonEnv->CreateIconL(iconPath2,0,1));
iListBx->ItemDrawer()->ColumnData()->SetIconArray(icons);
CDesCArray* aArray = (CDesCArray*) iListBx->Model()->ItemTextArray();
HBufC* item1 = iEikonEnv->AllocReadResourceL(R_DEMO_MENU_CMS);
HBufC* item2 = iEikonEnv->AllocReadResourceL(R_DEMO_MENU_BS);
aArray->AppendL(*item1);
aArray->AppendL(*item2);
iListBx->HandleItemAdditionL();
iListBx->MakeVisible(ETrue);
delete pos;
delete siz;
delete item1;
delete item2;
----------------------------------------------------------
奇怪的是,这段程序如果我把加图标的部分去掉,即Listbox中只使用文字,则可以正确执行。
可是一旦图片和文字都有,程序运行就出错了,什么都显示不出来,然后就出要求发送错误报告的
对话框。
这是什么原因造成的?