×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    34

    Exclamation Urgent! Issues with views.

    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.
    Code:
    .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
    =============================================================================================================================
    
    =====
    #ifndef RECORDERCONTAINER_H
    #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]
    Last edited by Nokia Ron; 2008-04-21 at 10:25. Reason: Wrap Code in Quotes

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: Urgent! Issues with views.

    You have apparently forgotten to mention how it does not work... Can you even navigate in the list for example? If not, check AddToStackL/RemoveFromStack methods and use them.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    34

    Re: Urgent! Issues with views.

    Dear Wizard Hu, thanks for the quick reply.

    I am able to browse/navigate the list when I press the up/down key. However when I press the select button (middle button), the app crashes and exits.

    I DO have the AddToStackL/RemoveFromStack methods.

    the code below is frm CRecorderView.cpp:

    CRecorderView::~CRecorderView()
    {

    if ( iContainer )
    {
    AppUi()->RemoveFromStack( iContainer );
    }

    delete iContainer;
    iContainer = NULL;

    }

    void CRecorderView:oActivateL(
    const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
    const TDesC8& /*aCustomMessage*/ )
    {

    iContainer = new( ELeave ) CRecorderContainer;
    // iContainer = CRecorderContainer::NewL(ClientRect());//d
    iContainer->SetMopParent(this);
    iContainer->ConstructL( ClientRect() );
    AppUi()->AddToStackL( *this, iContainer );

    //RLine can't be used in debugger
    #ifdef __WINS__
    #else

    #endif
    }


    Any suggestions and solution will be greatly appreciated. Thanks.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: Urgent! Issues with views.

    If it crashes, you can get the panic code: http://wiki.forum.nokia.com/index.ph...ded_panic_code

  5. #5
    Registered User
    Join Date
    Jan 2007
    Posts
    34

    Re: Urgent! Issues with views.

    Dear Wizard Hu,
    Thanks for the quick reply.
    I've created an file blank (0B) file named ErrRd in c:\system\Bootdata on my device as per the instructions from the link that you have given me. However there was no error message shown. I've read somewhere in FN that this will not work with S60 2nd ed FP2. I'm using FP2. Please advise. thanks.

Similar Threads

  1. problem with Views and Forms.
    By abhicreation in forum Symbian User Interface
    Replies: 3
    Last Post: 2007-05-24, 11:48
  2. VERY URGENT: views and dialogs
    By djazia in forum Symbian User Interface
    Replies: 2
    Last Post: 2005-05-13, 02:50
  3. Replies: 2
    Last Post: 2003-07-08, 13:39
  4. Views! Urgent
    By abrahim in forum Symbian User Interface
    Replies: 3
    Last Post: 2003-05-16, 13:52
  5. URGENT tabs and views
    By djazia in forum Symbian User Interface
    Replies: 1
    Last Post: 2002-12-12, 11:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×