Dear all,
I'm currently programming in C++ using carbide.c++ 1.1 on S60 2nd ed.
What I am trying to achieve is this:
I have a listbox to display choices that can be highlighted for selection. Upon selecting ('clicking') a choice on the listbox, the user will be directed to another view.
I have read and tried everything in forum nokia. However it is still not working. This is really frustrating as I understand
it is something that can be achieved very easily. I really need some answers VERY URGENTLY. I will be very grateful for all your help.
Posted below are my codes. Please tell me what have I done wrong, or maybe I've overlooked something.
My many thanks in advance.
#ifndef RECORDERCONTAINER_HCode:.cpp file ================================================================= */ // INCLUDE FILES #include <aknview.h> #include <avkon.hrh> #include <aknconsts.h> #include <coemain.h> #include <barsread.h> #include <aknappui.h> #include <eikprogi.h> //label #include <eiklabel.h> #include "RecorderContainer.h" #include "Recorder.hrh"//d #include "RecorderAppUi.h"//d #include <akntitle.h> #include <eiklbo.h>//d #include <aknlists.h> // CAknSingleStyleListBox //d //d #include <Recorder.rsg> // R_RECORDER_SETTING_ITEM_LIST #include <akniconarray.h> // CAknIcon #include <barsread.h> // TResource Reader #include <eikclbd.h> // CColumnListBoxData #include <eikmenub.h> // CEikMenuBar #include <stringloader.h> // StringLoader #include <uikon.hrh> // TKeyCode #defines #include "RecorderView.h" //#include <aknviewappui.h> // TKeyCode #defines #define KListPosition TPoint(0,0) //d class CRecorderAppUi; // CONSTANTS // ================= MEMBER FUNCTIONS ======================= // --------------------------------------------------------- // CREcorderContainer::CRecorderContainer() // C++ default constructor // --------------------------------------------------------- CRecorderContainer::CRecorderContainer() { } // --------------------------------------------------------- // CRecorderContainer::ConstructL() // EPOC default constructor can leave. // --------------------------------------------------------- void CRecorderContainer::ConstructL( const TRect& aRect ) { CreateWindowL(); // Create the list CreateListL();//d // Observe the list iSavedGamesListBox->SetListBoxObserver(this); // Set up scroll bars SetupScrollBarsL();//d SetRect( aRect ); ActivateL(); } // --------------------------------------------------------- // CRecorderContainer::~CREcorderContainer() // Destructor // --------------------------------------------------------- CRecorderContainer::~CRecorderContainer() { delete iSavedGamesListBox;//d } // --------------------------------------------------------- // CRecorderContainer::SizeChanged() // UI components' size are recalculated // --------------------------------------------------------- void CRecorderContainer::SizeChanged() { iSavedGamesListBox->SetExtent (KListPosition, iSavedGamesListBox->MinimumSize());//d } // --------------------------------------------------------- // CRecorderContainer::CountComponentControls() const // amount of component controls // --------------------------------------------------------- // TInt CRecorderContainer::CountComponentControls() const { return 1; } // --------------------------------------------------------- // CRecorderContainer::ComponentControl( TInt aIndex ) const // Ptr to each component controls // --------------------------------------------------------- // CCoeControl* CRecorderContainer::ComponentControl( TInt aIndex ) const { switch (aIndex) { case 0: { return iSavedGamesListBox; break; } default: return NULL; } } // --------------------------------------------------------- // CRecorderContainer::Draw( const TRect& aRect ) const // Draw function // --------------------------------------------------------- // void CRecorderContainer::Draw( const TRect& aRect ) const { CWindowGc& gc = SystemGc(); gc.Clear(aRect); } void CRecorderContainer::HandleControlEventL( CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) { } /** * Called by the framework whenever a list event occurs for which this container * is an observer. * @param aListBoxEvent The type of event which occured * */ void CRecorderContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aListBoxEvent)//d { // if the Select Key has been pressed if (aListBoxEvent == EEventEnterKeyPressed) { Select(); } } void CRecorderContainer::CreateListL()//d { // First phase construction iSavedGamesListBox = new (ELeave) CAknSingleGraphicStyleListBox; iSavedGamesListBox->SetContainerWindowL(*this); // Second Phase Construction TResourceReader reader; iEikonEnv->CreateResourceReaderLC(reader, R_RECORDER_SAVED_GAMES_LISTBOX); iSavedGamesListBox->ConstructFromResourceL(reader); CleanupStack::PopAndDestroy(); // reader } /** * Creates vertical scrollbars for the list, which appear automatically when required. */ void CRecorderContainer::SetupScrollBarsL()//d { iSavedGamesListBox->CreateScrollBarFrameL(ETrue); iSavedGamesListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); } /** * Called by the framework whenever a key event occurs. * Passes the key event to the saved games list if it is not null, otherwise returns * EKeyWasNotConsumed * @param aKeyEvent the Key event which occured, e.g. select key pressed * @param aType the type of Key event which occurred, e.g. key up, key down * @return TKeyResponse EKeyWasNotConsumed if the key was not processed, EKeyWasConsumed if it was */ TKeyResponse CRecorderContainer:: OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) { if(iSavedGamesListBox) { return iSavedGamesListBox->OfferKeyEventL(aKeyEvent,aType); } else { return EKeyWasNotConsumed; } } void CRecorderContainer::Select() { iAppUi->ActivateLocalViewL(TUid::Uid(ERecorderView2Tab)); } // End of File ============================================================================================================================= ====================================================================== Header File ============================================================================================================================= =====
#define RECORDERCONTAINER_H
// INCLUDES
#include <coecntrl.h>
#include <aknview.h>
#include "Recorder.hrh"
#include <eikon.hrh>
#include <eiklbo.h>//d
#include "RecorderAppUi.h"
// FORWARD DECLARATIONS
class CEikProgressInfo;
class CAknTitlePane;
class CEikLabel;
class CAknColumnListBox;//d
class CRecorderAppUi;//d
// CLASS DECLARATION
/**
* CRecorderContainer container control class.
*
*/
class CRecorderContainer : public CCoeControl, MEikListBoxObserver, MCoeControlObserver //d
{
public: // Constructors and destructor
/**
* CRecorderContainer()
*
* @discussion C++ default constructor.
*/
CRecorderContainer();
/**
* ConstructL()
*
* @discussion EPOC default constructor.
* @param aRect Frame rectangle for container.
*
*/
void ConstructL( const TRect& aRect );
/**
* ~CRecorderContainer()
*
* @discussion Delete UI componets.
*/
virtual ~CRecorderContainer();
public: // New functions
void CRecorderContainer::Select();//d
/**
* SetInfo()
*
* @discussion Set active or deactive text to infotext label .
* @param ETrue = active, EFalse = deactive.
*/
void SetInfo(TBool active);
private: // Functions from base classes
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
void CreateListL();//d
void SetupScrollBarsL();//d
/**
* CountComponentControls()
*
* @discussion From CoeControl,CountComponentControls.
* @return amount of component controls,
* in this application, this is the
* number of progress bars.
*/
TInt CountComponentControls() const;
/**
* ComponentControl()
*
* @discussion From CCoeControl,ComponentControl.
* @param each component controls in order
* @return Ptr to each component controls
*/
CCoeControl* ComponentControl( TInt aIndex ) const;
/**
* Draw()
* @discussion From CCoeControl,Draw.
* @param Frame rectangle for container
*/
void Draw( const TRect& aRect ) const;
/**
* SizeChange()
*
* @discussion Calculate new sizes of UI components
*/
void SizeChanged();
/**
* From MCoeControlObserver
* @param aControl each component controls
* @param aEventType event type
*/
void HandleControlEventL(
CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ );
void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aListBoxEvent);//d
private: //data
CRecorderAppUi* iAppUi;//d
CAknTitlePane* iTitlePane;
CAknColumnListBox* iSavedGamesListBox; // the saved games list d
};
#endif
// End of File
[/CODE]

Reply With Quote
oActivateL(

