listbox problem

Login to reply to this topic.
Wed, 2005-08-17 15:51
Joined: 2005-04-29
Forum posts: 65
Hi
I am want to display a listbox to be displayed when I open the application. so I have modified the appview file to do so.
but my application abnormally closes. The appview file is as follows:-

Code:
#include <coemain.h>
#include <aknlists.h>
[quote]#include <eiksbfrm.h>
#include <akniconarray.h>
#include <icon.mbg>
#include <gulicon.h>
#include <eiktxlbx.h>
#include <badesca.h>
#include <eikclbd.h>


#include "CallReportAppView.h"
#include "CallReport.rsg"

// Standard construction sequence
CCallReportAppView *CCallReportAppView::NewL(const TRect& aRect)
{
    CCallReportAppView *self = CCallReportAppView::NewLC(aRect);
    CleanupStack::Pop(self);
    return self;
}

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

CCallReportAppView::CCallReportAppView()
{
// no implementation required
}

CCallReportAppView::~CCallReportAppView()
{
// no implementation required
delete _listBox;
}

void CCallReportAppView::ConstructL(const TRect& aRect)
{
    // Create a window for this application view
    CreateWindowL();
    SetRect(aRect);
   
// Creation, initialization
_listBox = new (ELeave) CAknSingleLargeStyleListBox;

_listBox->SetContainerWindowL(*this);
_listBox->ConstructL(this,0);        // parent: container, use default flags
    _listBox->SetRect(aRect.Size());
    _listBox->ActivateL();
    _listBox->SetDimmed(ETrue);
_listBox->CreateScrollBarFrameL(ETrue);
_listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);   

_LIT(KIconsFilename, "Z:\\System\\Data\\icon.mbm");
CArrayPtr<CGulIcon>* iconList = new (ELeave) CAknIconArray(10);
CleanupStack::PushL(iconList);

// Icons are referenced by their physical position in .mbm file
iconList->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmIconIcon, EMbmIconIconmask));
iconList->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmIconNotifier,EMbmIconNotifiermask));
iconList->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmIconSettings, EMbmIconSettingsmask));
CleanupStack::Pop();
_listBox->ItemDrawer()->ColumnData()->SetIconArray(iconList);

//items

CTextListBoxModel* model = _listBox->Model();
MDesCArray* textArray = model->ItemTextArray();
CDesCArray* listBoxItems = static_cast<CDesCArray*>(textArray);
_LIT(KItemName1,"MyNewItem1");
_LIT(KItemName2,"MyNewItem2");
_LIT(KItemName3,"MyNewItem3");
TBuf<32> item;
item.Format(_L("%d\t%S\t%d"), 0, &KItemName1,0); // 0, 1, 2 = icon indexes in iconlist
listBoxItems->AppendL(item);
item.Format(_L("%d\t%S\t%d"), 1, &KItemName2,1); // 0, 1, 2 = icon indexes in iconlist
listBoxItems->AppendL(item);
item.Format(_L("%d\t%S\t%d"), 2, &KItemName3,2); // 0, 1, 2 = icon indexes in iconlist
listBoxItems->AppendL(item);
_listBox->HandleItemAdditionL(); // Update listbox
_listBox->SetCurrentItemIndexAndDraw(listBoxItems->Count() - 1); // select new

  model = _listBox->Model();
model->SetItemTextArray(listBoxItems);
model->SetOwnershipType(ELbmOwnsItemArray); // transfers ownership


    // Activate the window, which makes it ready to be drawn
    ActivateL();
    MakeVisible(ETrue);
}

// Draw this application's view to the screen
void CCallReportAppView::Draw(const TRect& /*aRect*/) const
{
    // Get the standard graphics context
    CWindowGc &gc = SystemGc();
   
    // Gets the control's extent
    TRect rect = Rect();
   
    // Clears the screen
    gc.Clear(rect);
}

TInt CCallReportAppView::CountComponentControls() const
    {
    return 1; // Only have one Component
    }

CCoeControl* CCallReportAppView::ComponentControl(TInt aIndex) const
    {
    switch(aIndex)
    {
    case 0:
    return _listBox;
default:
return NULL;
    }
    }

TKeyResponse CCallReportAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    return _listBox->OfferKeyEventL(aKeyEvent, aType);
    }

void CCallReportAppView::SizeChanged()
{

}

Please help me solving out this problem
thanx

Thu, 2005-08-18 05:05
Joined: 2003-04-01
Forum posts: 142
Re: listbox problem
you know, it would help quite a lot if you could tell us the error note shown during the crash. Also if you could run the application in your emulator and find out the line-of-your-code that is raising the exception, it would also make it easier to figure out the reason for the error.
yucca
  • Login to reply to this topic.