Hi, Once i wrote file manager for n-gage(like Fexplorer) , but it was without icons , but works well ....Now I decide to add icons , new program is build without errors ......in first screen icons shown(in this case I add items by hand) , when I decide to enter in some folder the program crash ......
There is piece ot my code
DR02Container.cpp
#include "DR02Container.h"
#include <eiklabel.h> // for example label control
#include <badesca.h>
#include <f32file.h>
#include <aknnotewrappers.h>
#include <eiklbv.h>
#include <apgcli.h>
void CDR02Container::ConstructL(const TRect& aRect)
{
first=0;
updown=0;
CreateWindowL();
iListBox = new (ELeave) CAknSingleGraphicPopupMenuStyleListBox;
iListBox->ConstructL(this, EAknListBoxMarkableList);
icons = new(ELeave)
CArrayPtrFlat<CGulIcon>(150);
iListBox->SetContainerWindowL(*this);
iListBox->SetRect(aRect.Size());
icons->AppendL(iEikonEnv->CreateIconL(_L("C:\\1.mbm"),0,1));
icons->AppendL(iEikonEnv->CreateIconL(_L("C:\\1.mbm"),0,1));
iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(icons);
_LIT(tmp,"");
bf=tmp;
CDesCArrayFlat* iListBoxRows = new (ELeave) CDesCArrayFlat(255);
iListBoxRows->AppendL(_L("0\tC:"));
iListBoxRows->AppendL(_L("1\tE:"));
iListBox->Model()->SetItemTextArray( iListBoxRows );
iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
iListBox->ActivateL();
//Items(bf);
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()
->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
// iListBox->SetListBoxObserver(this);
iListBox->SetFocus(ETrue, EDrawNow);
//iListBox->SetSelectionIndexesL(2);
SetRect(aRect);
ActivateL();
MakeVisible(ETrue);
}
// Destructor
CDR02Container::~CDR02Container()
{
//delete iLabel;
//delete iToDoLabel;
delete iListBox;
}
// ---------------------------------------------------------
// CDR02Container::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CDR02Container::SizeChanged()
{
// TODO: Add here control resize code etc.
//iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
iListBox->SetExtent( TPoint(0,0), iListBox->MinimumSize() );
}
// ---------------------------------------------------------
// CDR02Container::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CDR02Container::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CDR02Container::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CDR02Container::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iListBox;
//case 1:
// return iToDoLabel;
default:
return NULL;
}
}
void CDR02Container::fss(TBuf16<255> path11)
{
RFs fsSession;
fsSession.Connect();
fsSession.GetDir(path11,KEntryAttMaskSupported,EDirsFirst,dirList);
fsSession.Close();
g=dirList->Count();
}
void CDR02Container::AddItems(TBuf16<255> path1)
{
_LIT(Ka,"0\t");
_LIT(P,"C:\\1.mbm");
TBuf16<40> buffer1[40];
fss(path1);
CDesCArray* array = static_cast<CDesCArray*>(iListBox->
Model()-> ItemTextArray());
array->Reset();
icons->Reset();
for (TInt i=0;i<g;i++)
{ icons->AppendL(iEikonEnv->CreateIconL(P,0,1));
buffer1[i]=Ka;
buffer1[i].Insert(buffer1[i].Length(),(*dirList)[1].iName);
array->AppendL(buffer1[i]);
} iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(icons);
iListBox->HandleItemAdditionL();
}
............................
..............................
DR02Container.h
.....
public: void Items(TBuf16<512> path);
TBuf16<255> bf;
TBuf16<255> bf1;
TBuf16<255> Refs();
CEikFormattedCellListBox* iListBox;
CArrayPtr<CGulIcon>* icons;
CDir* dirList;
TInt g;
..........
private: //data
// example label
TDriveList* aList;
TInt first;
TInt updown;
....
Can anyone help me???
PP: excuse my english :P

Reply With Quote

