Hi,
All Happy new year .....................!!!!!!!
I am working on Symbian C++ (S60) in codewarrior............ I am facing a problem in showing my icons in my grids. I have done the same thing in Listbox and its working fine ....... here i can display the text in the grids ..... I have six grids and i want to display icons over it ...... but its not working even though code is compiled successfully... plz help me ..... I am sending my container.cpp file and .rss file ..

//------------------------------------------------------------
//MultiViewsContainer1.cpp
//------------------------------------------------------------

#include <MultiViews.rsg>
#include <MULTIVIEWS.mbg>

#include "MultiViewsContainer1.h"

#include <AknGrid.h>
#include <AknGridView.h>
#include <AknGridM.h>
#include <AknIconArray.h>
#include <AknLists.h>
#include <AknQueryDialog.h>

#include <barsread.h>
#include <coemain.h>

#include <e32base.h>
#include <GULICON.H>
//constants
const TInt KNumberOfIcons = 6;//the count if icon
const TInt KGraphicsHeight = 28;//icon height
const TInt KTextColor = 215;//text color



//AknLists.h
// ========================= MEMBER FUNCTIONS ==================================


// -----------------------------------------------------------------------------
// CMultiViewsContainer1::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CMultiViewsContainer1* CMultiViewsContainer1::NewL( const TRect& aRect )
{
CMultiViewsContainer1* self = CMultiViewsContainer1::NewLC( aRect );
CleanupStack::Pop( self );
return self;
}

// -----------------------------------------------------------------------------
// CMultiViewsContainer1::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CMultiViewsContainer1* CMultiViewsContainer1::NewLC( const TRect& aRect )
{
CMultiViewsContainer1* self = new ( ELeave ) CMultiViewsContainer1;
CleanupStack::PushL( self );
self->ConstructL( aRect );
return self;
}

// -----------------------------------------------------------------------------
// CMultiViewsContainer1::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CMultiViewsContainer1::ConstructL( const TRect& aRect )
{
CreateWindowL();

iGrid = new( ELeave ) CAknGrid;
iGrid->SetContainerWindowL( *this );

TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SELECTIONGRID);
iGrid->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy();


// Setup the text subcell

AknListBoxLayouts::SetupFormTextCell(

*iGrid, // Reference to grid

iGrid->ItemDrawer(),// Pointer to the item drawer

1, // Column index

LatinBold12(), // Font

215, // Color (215 = black)

0, // Left margin

0, // Right margin - unused

50 - 3, // Baseline

50, // Text width

CGraphicsContext::ECenter, // Text alignment

TPoint(0, 32), // Start position

TPoint(50, 50)); // End position


iGrid->MakeVisible( ETrue );
iGrid->SetFocus( ETrue );
iGrid->ActivateL();

//icon display

SetupGridIconsL();
SizeChanged();
SetRect( aRect );
ActivateL();


DrawNow();
}

void CMultiViewsContainer1::SetupGridIconsL()
{
_LIT(KIconsFilename, "\\system\\apps\\multiviews\\multiviews.mbm");


CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(KNumberOfIcons);
CleanupStack::PushL(icons);
icons->AppendL(CEikonEnv::Static()->CreateIconL(KIconsFilename, EMbmMultiviewsGriditem , EMbmMultiviewsGriditemm));
icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsTrains, EMbmMultiviewsTrainsm));
icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsAirways, EMbmMultiviewsAirwaysm));
icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsGriditem , EMbmMultiviewsGriditemm));
icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsTrains, EMbmMultiviewsTrainsm));
icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsAirways, EMbmMultiviewsAirwaysm));

CleanupStack::Pop(icons);


iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons); // passing ownership of icons



}

CMultiViewsContainer1::CMultiViewsContainer1()
{

}

CMultiViewsContainer1::~CMultiViewsContainer1()
{
delete iGrid;
}


/*void CMultiViewsContainer1::SizeChanged()
{

if(iGrid)
{
iGrid->SetRect(Rect());
}

}
*/
#define KGridPosition TPoint(0,0)

void CMultiViewsContainer1::SizeChanged()
{
if (iGrid)
{
iGrid->SetExtent(KGridPosition,Rect().Size());
}
}




void CMultiViewsContainer1::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{

}


TKeyResponse CMultiViewsContainer1::OfferKeyEventL(
const TKeyEvent& aKeyEvent,
TEventCode aType )
{

if(iGrid)
return iGrid->OfferKeyEventL( aKeyEvent, aType );
else
return EKeyWasNotConsumed;
}


// -----------------------------------------------------------------------------
// CMultiViewsContainer1::CountComponentControls() const
// returns number of controls inside this container.
// -----------------------------------------------------------------------------
//
TInt CMultiViewsContainer1::CountComponentControls() const
{
return 1;
}


// -----------------------------------------------------------------------------
// CMultiViewsContainer1::ComponentControl() const
// returns pointer of controls inside this container
// -----------------------------------------------------------------------------
//
CCoeControl* CMultiViewsContainer1::ComponentControl( TInt aIndex ) const
{
switch ( aIndex )
{
case 0:
return iGrid;

default:
return NULL;
}
}

// -----------------------------------------------------------------------------
// CMultiViewsContainer1::Draw() const
// Draws the display
// -----------------------------------------------------------------------------
//
void CMultiViewsContainer1::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( TRgb(0xfff123)); //KRgbBlue );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}



TInt CMultiViewsContainer1::UpdateFromModelGrid()
{

pos = iGrid->CurrentDataIndex();
if(pos==0)
{
..........
.............................
}
........................................
.......................................................

else
{
iEikonEnv->InfoMsg( _L("You have pressed Ok button 6") );
return 6;
}


}


// End of File
//------------------------------------------------------------------------


// .RSS file
RESOURCE GRID r_selectiongrid
{ array_id = r_selectiongrid_items;
flags = EAknListBoxSelectionGrid;
style = r_selectiongrid_style;
}
RESOURCE GRID_STYLE r_selectiongrid_style
{ layoutflags = EAknGridHorizontalOrientation | EAknGridLeftToRight | EAknGridTopToBottom;
primaryscroll = EAknGridFollowsItemsAndLoops;
secondaryscroll = EAknGridFollowsItemsAndLoops;
itemsinprimaryorient = 3;
itemsinsecondaryorient = 3;
gapwidth = 5;
gapheight = 5;
width = 55;
height = 70;
}

RESOURCE ARRAY r_selectiongrid_items
{
items =
{ LBUF { txt = "0\tHospitals"; },
LBUF { txt = "1\tRestaurant"; },
LBUF { txt = "2\tATMs"; },
LBUF { txt = "0\tEntertainment"; },
LBUF { txt = "2\tGenie"; } ,
LBUF { txt = "3\tPetrol Pumps"; } //,

};
}