Hi,
I need to raed contacts from phone and show in a list box. I have code to read contacts. list box is ready. need to convert read contactdetails ContactItem* to CDesCArrayFlat
I have the following code which is called from AppUi::handleCommandl()
CContactDatabase* contactsDb = CContactDatabase::OpenL();
CleanupStack::PushL(contactsDb);
// Get the ID of the own card and open the contact:
TContactItemId ownCardId = contactsDb->OwnCardId();
if (ownCardId == KNullContactId )
User::Leave(KNullContactId );
//Own card may not be set
CContactItem* ownCard = contactsDb->ReadContactL(ownCardId);
CleanupStack::PushL(ownCard);
TInt count = ownCard->CardFields().Count();
contactsDb->CloseContactL(ownCard->Id());
CleanupStack::PopAndDestroy(2); // ownCard, contactsDb



CDesCArray* array = new (ELeave) CDesCArrayFlat(3);
iSearchList->MakeVisible(EFalse);
//iDetailedView = ETrue;
iSearchList->Model()->SetItemTextArray(array);
iSearchList->MakeVisible(ETrue);
iSearchList->SetCurrentItemIndexAndDraw(0);
SizeChanged();
iSearchList->ActivateL();


following code in AppView->constructL()
CreateWindowL();

iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);

iSearchList = new (ELeave) CAknSingleStyleListBox();
iSearchList->ConstructL(this);
iSearchList->SetContainerWindowL(*this);
iSearchList->CreateScrollBarFrameL(ETrue);
iSearchList->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOn,
CEikScrollBarFrame::EAuto);

iItemList = new (ELeave) CDesCArrayFlat(3);
iSearchList->Model()->SetItemTextArray(iItemList);
iSearchList->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);

iDetailList = new (ELeave) CAknFormDoubleStyleListBox;
iDetailList->ConstructL(this);
iDetailList->SetContainerWindowL(*this);
iDetailList->CreateScrollBarFrameL(ETrue);
iDetailList->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOn,
CEikScrollBarFrame::EAuto);
iDetailList->Model()->SetOwnershipType(ELbmOwnsItemArray);
iDetailList->MakeVisible(EFalse);
iSearchList->MakeVisible(ETrue); // show "no results" at startup
iSearchList->SetListBoxObserver(this);
SetRect(aRect);
ActivateL();
MakeVisible(ETrue);


following code in appview::draw()
CWindowGc& gc = SystemGc();

gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbWhite );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );

gc.UseFont(iFont);
TInt lineHeight = iFont->HeightInPixels()+1;

const TInt col = 5;
gc.DrawText(KAboutString1, TPoint(col, lineHeight));
gc.DrawText(KAboutString2, TPoint(col, lineHeight*2));
gc.DrawText(KAboutString3, TPoint(col, lineHeight*3));
gc.DrawText(KAboutString4, TPoint(col, lineHeight*4));
gc.DrawText(KAboutString5, TPoint(col, lineHeight*5));