×

Discussion Board

Results 1 to 8 of 8

Thread: ListBox Errors

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    ListBox Errors

    I am trying to build a basic listbox on Symbian OS 7.0 using Carbide c++ with SDK 2.0. The following code was copied to the ConstructL function of the Container class

    The following is the Container c++ file:

    /*
    ============================================================================
    Name : SKJListContainer.cpp
    Author :
    Copyright : Your copyright notice
    Description : Container control implementation
    ============================================================================
    */

    // INCLUDE FILES
    #include "SKJListContainer.h"
    //#include <eikclb.h>
    #include <eiklabel.h> // for example label control
    #include <badesca.h>

    // ================= MEMBER FUNCTIONS =======================

    // ---------------------------------------------------------
    // CSKJListContainer::ConstructL(const TRect& aRect)
    // EPOC two phased constructor
    // ---------------------------------------------------------
    //
    void CSKJListContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    /*
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Example View") );

    iToDoLabel = new (ELeave) CEikLabel;
    iToDoLabel->SetContainerWindowL( *this );
    iToDoLabel->SetTextL( _L("Add Your controls\n here") );
    */

    //SKJ List Box - Start
    // listbox item format string
    _LIT(KListItemFormat, "%d\t%S\t\t");
    // listbox instance
    list = new (ELeave) CAknSingleNumberStyleListBox;
    // construct listbox
    list->ConstructL(this);
    // set container control
    list->SetContainerWindowL(*this);
    // add scrollbars to listbox
    list->CreateScrollBarFrameL(ETrue);
    list->ScrollBarFrame()->SetScrollBarVisibilityL(
    CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
    // construct listbox item array
    CDesCArray *itemList = new (ELeave) CDesCArrayFlat(3);
    TBuf<32> item;
    TInt idx=1;
    // append items to the listbox, incrementing numbering
    item.Format(KListItemFormat, idx, _L("first item"));
    itemList->AppendL(item); idx++;
    item.Format(KListItemFormat, idx, _L("another item"));
    itemList->AppendL(item); idx++;
    item.Format(KListItemFormat, idx, _L("last item"));
    itemList->AppendL(item); idx++;
    // set items and ownership
    list->Model()->SetItemTextArray(itemList);
    list->Model()->SetOwnershipType(ELbmOwnsItemArray);
    // update listbox
    list->HandleItemAdditionL();

    //SKJ List Box - End
    SetRect(aRect);
    ActivateL();
    }

    // Destructor
    CSKJListContainer::~CSKJListContainer()
    {
    /* delete iLabel;
    delete iToDoLabel;
    */
    }

    // ---------------------------------------------------------
    // CSKJListContainer::SizeChanged()
    // Called by framework when the view size is changed
    // ---------------------------------------------------------
    //
    void CSKJListContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    /*
    iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
    iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize() );
    */
    }

    // ---------------------------------------------------------
    // CSKJListContainer::CountComponentControls() const
    // ---------------------------------------------------------
    //
    TInt CSKJListContainer::CountComponentControls() const
    {
    // return 2; // return nbr of controls inside this container
    return 1;
    }

    // ---------------------------------------------------------
    // CSKJListContainer::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CSKJListContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    /*case 0:
    return iLabel;
    case 1:
    return iToDoLabel;
    */
    case 0:return list;
    default:
    return NULL;
    }
    }

    // ---------------------------------------------------------
    // CSKJListContainer::Draw(const TRect& aRect) const
    // ---------------------------------------------------------
    //
    void CSKJListContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

    // ---------------------------------------------------------
    // CSKJListContainer::HandleControlEventL(
    // CCoeControl* aControl,TCoeEvent aEventType)
    // ---------------------------------------------------------
    //
    void CSKJListContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }



    And the following is the Container header file:

    /*
    ============================================================================
    Name : SKJListContainer.h
    Author :
    Copyright : Your copyright notice
    Description : Declares container control for application.
    ============================================================================
    */

    #ifndef SKJLISTCONTAINER_H
    #define SKJLISTCONTAINER_H

    // INCLUDES
    #include <coecntrl.h>
    #include <aknlists.h>


    // FORWARD DECLARATIONS
    class CEikLabel; // for example labels

    // CLASS DECLARATION

    /**
    * CSKJListContainer container control class.
    *
    */
    class CSKJListContainer : public CCoeControl, MCoeControlObserver
    {
    public: // Constructors and destructor

    /**
    * EPOC default constructor.
    * @param aRect Frame rectangle for container.
    */
    void ConstructL(const TRect& aRect);

    /**
    * Destructor.
    */
    ~CSKJListContainer();

    public: // New functions

    public: // Functions from base classes

    private: // Functions from base classes

    /**
    * From CoeControl,SizeChanged.
    */
    void SizeChanged();

    /**
    * From CoeControl,CountComponentControls.
    */
    TInt CountComponentControls() const;

    /**
    * From CCoeControl,ComponentControl.
    */
    CCoeControl* ComponentControl(TInt aIndex) const;

    /**
    * From CCoeControl,Draw.
    */
    void Draw(const TRect& aRect) const;


    /**
    * From MCoeControlObserver
    * Acts upon changes in the hosted control's state.
    *
    * @param aControl The control changing its state
    * @param aEventType The type of control event
    */
    void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);

    private: //data

    /* CEikLabel* iLabel; // example label
    CEikLabel* iToDoLabel; // example label
    */
    CAknColumnListBox* list;
    };

    #endif



    And the following errors result:

    >Undefined symbol: 'CDesC16ArrayFlat::CDesC16ArrayFlat(int) (??0CDesC16ArrayFlat@@QAE@H@Z)'
    >referenced from 'void CSKJListContainer::ConstructL(class TRect const &) (?ConstructL@CSKJListContainer@@QAEXABVTRect@@@Z)' in SKJListContainer.cpp:50
    mwldsym2.exe|Linker|Error
    >Undefined symbol: 'void CDesC16Array::AppendL(class TDesC16 const &) (?AppendL@CDesC16Array@@QAEXABVTDesC16@@@Z)'
    >referenced from 'void CSKJListContainer::ConstructL(class TRect const &) (?ConstructL@CSKJListContainer@@QAEXABVTRect@@@Z)' in SKJListContainer.cpp:55
    >referenced from 'void CSKJListContainer::ConstructL(class TRect const &) (?ConstructL@CSKJListContainer@@QAEXABVTRect@@@Z)' in SKJListContainer.cpp:57
    >referenced from 'void CSKJListContainer::ConstructL(class TRect const &) (?ConstructL@CSKJListContainer@@QAEXABVTRect@@@Z)' in SKJListContainer.cpp:59
    mwldsym2.exe|Linker|Error
    >Undefined symbol: 'class CTextListBoxModel * CEikColumnListBox::Model(void) const (?Model@CEikColumnListBox@@QBEPAVCTextListBoxModel@@XZ)'
    >referenced from 'void CSKJListContainer::ConstructL(class TRect const &) (?ConstructL@CSKJListContainer@@QAEXABVTRect@@@Z)' in SKJListContainer.cpp:61
    >referenced from 'void CSKJListContainer::ConstructL(class TRect const &) (?ConstructL@CSKJListContainer@@QAEXABVTRect@@@Z)' in SKJListContainer.cpp:62

    From what I could see, declaring the array was a problem. I must most probably be missing to include the appropriate header file or the library file for the CDesC16ArrayFlat class. But, I suppose, including the #include <badesca.h> should solve the problem but it doesn't!

    Please help - I tried searching a lot of places but in vain.

    Thanks!

  2. #2
    Super Contributor
    Join Date
    Jul 2006
    Location
    Oulu, Finland.
    Posts
    1,174

    Re: ListBox Errors

    hi,

    Just have a look at the example i have posted for Creating list box from a file.

    Just go through it and try this example : http://discussion.forum.nokia.com/fo...ad.php?t=77730

    GoodLuck.
    vasant

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Smile Re: ListBox Errors

    Hi,

    Quote Originally Posted by javadi82
    ....I must most probably be missing to include the appropriate header file or the library file for the CDesC16ArrayFlat class. But, I suppose, including the #include <badesca.h> should solve the problem but it doesn't!
    You need to link against bafl.lib

    Class CDesC16ArrayFlat
    Location: badesca.h
    Link against: bafl.lib
    Whenever you find such linking problem, just refer to the SDK help.
    You shall get required information from there.

    Regards.
    Kiran.

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Re: ListBox Errors

    I am currently using Carbide.c++ Version 1.0 and there is no .mmp file that is created with the project.

    So doing something like : #include <bafl.lib>
    in the Container.h file or the Container.cpp is resulting in an error.

    Thanks!

    [UPDATE]: Here is the link which explains how this is done:

    http://www3.symbian.com/faq.nsf/0/D3...A?OpenDocument
    Last edited by javadi82; 2006-11-08 at 12:03.

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Smile Re: ListBox Errors

    Hi,

    See Post #6 from the following link:
    http://discussion.forum.nokia.com/fo...ad.php?t=90708

    One more relevant thread: http://discussion.forum.nokia.com/fo...ad.php?t=92497

    Regards.
    Kiran.
    Last edited by kiran10182; 2006-11-08 at 11:57. Reason: Informative link added.

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Re: ListBox Errors

    Now, there are none of the compile errors(!) But when I run the application now - It closes!

    Here is the full source code for the Container.cpp:

    Please please have a look.

    /*
    ============================================================================
    Name : SKJListContainer.cpp
    Author :
    Copyright : Your copyright notice
    Description : Container control implementation
    ============================================================================
    */

    // INCLUDE FILES
    #include "SKJListContainer.h"
    //#include <eikclb.h>
    #include <eiklabel.h> // for example label control
    #include <badesca.h>

    // ================= MEMBER FUNCTIONS =======================

    // ---------------------------------------------------------
    // CSKJListContainer::ConstructL(const TRect& aRect)
    // EPOC two phased constructor
    // ---------------------------------------------------------
    //
    void CSKJListContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    /*
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Example View") );

    iToDoLabel = new (ELeave) CEikLabel;
    iToDoLabel->SetContainerWindowL( *this );
    iToDoLabel->SetTextL( _L("Add Your controls\n here") );
    */

    //SKJ List Box - Start
    // listbox item format string
    _LIT(KListItemFormat, "%d\t%S\t\t");
    // listbox instance
    list = new (ELeave) CAknSingleNumberStyleListBox;
    // construct listbox
    list->ConstructL(this);
    // set container control
    list->SetContainerWindowL(*this);
    // add scrollbars to listbox
    list->CreateScrollBarFrameL(ETrue);
    list->ScrollBarFrame()->SetScrollBarVisibilityL(
    CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
    // construct listbox item array
    CDesCArray *itemList = new (ELeave) CDesCArrayFlat(3);
    TBuf<32> item;
    TInt idx=1;
    // append items to the listbox, incrementing numbering
    item.Format(KListItemFormat, idx, _L("first item"));
    itemList->AppendL(item); idx++;
    item.Format(KListItemFormat, idx, _L("another item"));
    itemList->AppendL(item); idx++;
    item.Format(KListItemFormat, idx, _L("last item"));
    itemList->AppendL(item); idx++;
    // set items and ownership

    CTextListBoxModel* model = list->Model();

    model->SetItemTextArray(itemList);
    model->SetOwnershipType(ELbmOwnsItemArray);
    // update listbox
    list->HandleItemAdditionL();

    //SKJ List Box - End
    SetRect(aRect);
    ActivateL();
    }

    // Destructor
    CSKJListContainer::~CSKJListContainer()
    {
    /* delete iLabel;
    delete iToDoLabel;
    */
    delete list;
    }

    // ---------------------------------------------------------
    // CSKJListContainer::SizeChanged()
    // Called by framework when the view size is changed
    // ---------------------------------------------------------
    //
    void CSKJListContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    /*
    iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
    iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize() );
    */
    list->SetRect(Rect());
    }

    // ---------------------------------------------------------
    // CSKJListContainer::CountComponentControls() const
    // ---------------------------------------------------------
    //
    TInt CSKJListContainer::CountComponentControls() const
    {
    // return 2; // return nbr of controls inside this container
    return 1;
    }

    // ---------------------------------------------------------
    // CSKJListContainer::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CSKJListContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    /*case 0:
    return iLabel;
    case 1:
    return iToDoLabel;
    */
    case 0:return list;
    default:
    return NULL;
    }
    }

    // ---------------------------------------------------------
    // CSKJListContainer::Draw(const TRect& aRect) const
    // ---------------------------------------------------------
    //
    void CSKJListContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

    // ---------------------------------------------------------
    // CSKJListContainer::HandleControlEventL(
    // CCoeControl* aControl,TCoeEvent aEventType)
    // ---------------------------------------------------------
    //
    void CSKJListContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }

  7. #7
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: ListBox Errors

    Hi javadi82,
    Please mention the panic code so that pple out here can help you much faster.
    giving junks of code and debuging it would make things worse. please debug ur code and figure out where does it crash..then post ur problem..that would make things much faster...
    hpe u understand.
    please have a look on how to get the panic code.. http://www.newlc.com/Display-the-ext...c-code-in.html

    Priju

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Smile Re: ListBox Errors

    Hello,

    Create one empty File named: ErrRd in the following path:
    ........\epoc32\wins\c\System\Bootdata\
    It will give you an error code when there is a problem with yr code.

    Enable the Extended panic option from the preferences of the emulator.

    And debug your code.
    Put some breakpoints in your code.
    And check on which line it is causing problem.

    Regards.
    Kiran.

Similar Threads

  1. Query ~ Listbox | functional but no text
    By series60nubee in forum Symbian
    Replies: 5
    Last Post: 2006-03-24, 06:09
  2. Using a "custom" listbox in mobile s60
    By ctpthanh in forum Symbian User Interface
    Replies: 4
    Last Post: 2005-04-17, 14:46
  3. Hide Listbox not working with MakeVisible(EFalse)
    By Salvesh in forum Symbian User Interface
    Replies: 3
    Last Post: 2005-02-04, 05:04
  4. listbox and model
    By stenlik in forum Symbian
    Replies: 1
    Last Post: 2004-05-27, 07:27
  5. ListBox and resource file
    By tplinet in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-04-02, 16: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
  •  
×