ListBox and icon problem....

Login to reply to this topic.
Fri, 2005-08-12 10:38
Joined: 2005-08-04
Forum posts: 27
hello all

i have problem with listbox and icon

here is my code what i have written in the

CMyFirstAppContainer::ConstructL(..)
{
iListBox = new (ELeave) CAknSingleLargeStyleListBox();   
   iListBox->SetContainerWindowL(*this);
   iListBox->ConstructL(this,EAknListBoxSelectionList);

   array = new (ELeave) CDesCArrayFlat(KGranularityOfArray);
   
   CleanupStack::PushL(array);
   array->AppendL(_L("0\tFirst item"));
   array->AppendL(_L("0\tSecond item"));
   array->AppendL(_L("0\tThird item"));
   array->AppendL(_L("0\tFourth item"));
   array->AppendL(_L("0\tFifth item"));
   CleanupStack::Pop();
   iListBox->Model()->SetItemTextArray(array);
   iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);

   //CArrayPtr* iconList = new (ELeave) CAknIconArray(5);
   CArrayPtr<CGulIcon>* iConList = new (ELeave) CAknIconArray(1);
   CleanupStack::PushL( iConList );

   //iConList->AppendL(iEikonEnv->CreateIconL(KMultiBitmapFilename, 2, -1));//EMbmSmsorLog, EMbmSmsorLog_mask
   iConList->AppendL(iEikonEnv->CreateIconL(_L("c:\\System\\Apps\\Myfirstapp\\Myfirstapp.mbm"), EMbmTestImage2));
   CleanupStack::Pop(iConList);
   //iListBox->iItemDrawer()->ColumnData()->SetIconArray(iConList);

   //iConList->AppendL(iEikonEnv->CreateIconL(KMultiBitmapFilename, EMbmIconIcon_24x24i,EMbmIconIcon_24x24m));

   CFormattedCellListBoxItemDrawer* drawer = (CFormattedCellListBoxItemDrawer*)iListBox->View()->ItemDrawer();
   drawer->ColumnData()->SetIconArray(iConList);
   CleanupStack::Pop();   
   
   //iListBox->HandleItemAdditionL();   

   iListBox->SetListBoxObserver(this);

    SetRect(aRect);
    ActivateL();

}

where is the problem?

i can display the listbox without icon but how can i display listbox and icon both

please give some tips

thanks

bashar

Fri, 2005-08-12 11:33
Joined: 2003-04-01
Forum posts: 142
Re: ListBox and icon problem....
maybe you could try using CAknSingleGraphicStyleListBox ?

yucca
Fri, 2005-08-12 13:07
Joined: 2005-08-04
Forum posts: 27
Re: ListBox and icon problem....
thanks

i have tried with that but it doesn't work

anyway thanks

bashar
Sat, 2005-08-13 03:01
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: ListBox and icon problem....
Try with the below code:

Code:
void CMyAppContainer::CreateListBoxL()
{
//Delete the list box if already exists.
if ( iListBox )
{
delete iListBox;
iListBox = NULL;
}
// listbox instance
iListBox = new (ELeave) CAknSingleLargeStyleListBox();
iListBox->ConstructL(this, EAknListBoxSelectionList);
iListBox->SetContainerWindowL(*this);

// add scrollbars to listbox
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn,
CEikScrollBarFrame::EAuto );

const TPoint aPoint(0,0);
const TSize aSize(180,150);

//most important line , else the list box simply disappears
iListBox->SetExtent(aPoint,aSize);

//Fill list box with the data
InitListBox();

iListBox->ActivateL();
iListBox->DrawNow();

iCtrlArray.Append( iListBox );
}

void CMyAppContainer::InitListBox()
{
CDesCArray *itemList = new (ELeave) CDesCArrayFlat(KGranularityOfArray);

itemList->AppendL(_L("0\tItem01"));
itemList->AppendL(_L("1\tItem02"));
itemList->AppendL(_L("2\tItem03"));
//...

// set items and ownership
iListBox->Model()->SetItemTextArray(itemList);
iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
iListBox->SetCurrentItemIndex(0);
iListBox->SetFocus(ETrue);

CArrayPtr<CGulIcon>* iconList = new (ELeave) CAknIconArray(KGranularityOfArray);
CleanupStack::PushL(iconList);
_LIT( KIconFile,"z:\\system\\data\\avkon.mbm");
iconList->AppendL( iEikonEnv->CreateIconL( KIconFile, EMbmAvkonQgn_note_ok, EMbmAvkonQgn_note_ok_mask) );
iconList->AppendL( iEikonEnv->CreateIconL( KIconFile, EMbmAvkonQgn_note_bt, EMbmAvkonQgn_note_bt_mask) );
iconList->AppendL( iEikonEnv->CreateIconL( KIconFile, EMbmAvkonQgn_note_sml, EMbmAvkonQgn_note_sml_mask) );

iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList );
CleanupStack::Pop(); // iconList
iListBox->HandleItemAdditionL();
}

Tue, 2006-02-21 17:22
Joined: 2004-12-06
Forum posts: 182
Re: ListBox and icon problem....
HI, 
how to giv different icons for each coloum?
hoping help
regs Julie

To err is human; to forgive, divine

Fri, 2006-10-20 02:24
Joined: 2006-10-19
Forum posts: 2
Re: ListBox and icon problem....
hi
vin2ktalks how are you declare    iListBox in CMyApContainer.h?
Mon, 2006-10-23 09:05
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: ListBox and icon problem....
I declared it in the header file like this:

Code:
CEikColumnListBox* iListBox;

Tue, 2008-06-03 08:46
Joined: 2006-12-15
Forum posts: 45
Re: ListBox and icon problem....

Hi vin2ktalks,

what is this array:--

iCtrlArray.Append( iListBox );

in the last line of CreateListBoxL() doing?

could u plz reply? I'm following ur code to make a graphics list box.


Tushar Bhattacharyya

  • Login to reply to this topic.