×

Discussion Board

Page 1 of 4 1234 LastLast
Results 1 to 15 of 48
  1. #1
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605

    List Box Problem

    m facing a problem in reading a selected value from List Box.

    I have created a list box from Resource( .rss file).

    I actually have put it on a Dialog.

    This is the code i write on OkToExitL() method of the dialog.
    ----------------------------------------------------------------------------
    / Get a pointer to the control.
    CCoeControl* myListBoxPtr = this->Control(EListBoxId);

    // Downcast the returned CCoeControl* pointer to the correct type.
    CEikTextListBox* myListBox = static_cast<CEikTextListBox*>( myListBoxPtr);

    TInt selectedIndex= myListBox->CurrentItemIndex();

    CTextListBoxModel* iModel= myListBox->Model();

    TPtrC a=iModel->ItemText(selectedIndex);
    ----------------------------------------------------------------------------

    But it fails the compile process and this is the error .

    Error : illegal use of incomplete struct/union/class 'CTextListBoxModel'
    ClockDlg.cpp line 220

    Error : Compile failed

    What can be the problem......

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    have you included header file that defines the CTextListBoxModel in your ClockDlg.cpp file.

    yucca

  3. #3
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    Thanks Yucca .May be that was the problem .It is passing the compile test now ..

    But i have never had such a type of error if u miss the header class.

    May be thats why i was struck with it as i thought it cannot be header related error.

    Thanks once again

  4. #4
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: List Box Problem

    hello Mr. symbianyucca
    This is my program from which i want to create list box without using resource....

    void Cview_list::ConstructL()
    {
    iListBox = new (ELeave) CAknSingleNumberStyleListBox();//CAknSingleNumberStyleListBox(); // markableCEikTextListBox();//
    // Construct listbox
    iListBox->ConstructL(this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
    iListBox->SetContainerWindowL( *this );
    // Set scrollbars
    iListBox->CreateScrollBarFrameL( ETrue );
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );

    // Create listbox item array
    iListBoxItems = new (ELeave) CDesCArrayFlat(4);
    // Create listbox items
    iListBoxItems->AppendL( _L("1\tItem") );
    iListBoxItems->AppendL( _L("2\tItem") );
    iListBoxItems->AppendL( _L("3\tItem") );
    // Add items to listbox
    iListBox->Model()->SetItemTextArray( iListBoxItems );
    // Listbox deletes the item array
    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
    iListBox->HandleItemAdditionL( );
    // Activate Listbox
    iListBox->SetRect( Rect() );
    iListBox->ActivateL();

    }
    void Cview_list::SizeChanged()
    {
    iListBox->SetRect( Rect() );
    }

    but i am getting errors like

    illegal use of incomplete struct/union/class 'CTextListBoxModel'

    undefined identifier 'CAknSingleNumberStyleListBox'

    undefined identifier 'EAknListBoxSelectionList'

    illegal use of incomplete struct/union/class 'CTextListBoxModel'
    kindly let me know what am i missing???
    thank you.

    Nishant

  5. #5
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,019

    Re: List Box Problem

    Search for all these classes in SDK & include their corresponding headers/libs in your cpp/mmp file.

  6. #6
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: List Box Problem

    thanks Vineet.
    I got it
    i forgot to add aknlist.h
    but now there is new problem..
    my program is crashing now.....
    please help me.
    Thanks..

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: List Box Problem

    Check the panic code, http://www.developer.nokia.com/Commu...ded_panic_code
    You can find a short, resource-less listbox example in http://www.developer.nokia.com/Commu...m-with-ListBox

  8. #8
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: List Box Problem

    Thanks wizard_hu_

    i am able to create list box but now i am not able to scroll it by up arrow key or down arrow key...
    is something am i missing??
    kindly tell me..
    thanks

  9. #9
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,019

    Re: List Box Problem

    You already have implemented OfferKeyEventL()? Wiki has number of articles on how to create listbox etc. ,you should have tried searching them, just like this one :

    http://www.developer.nokia.com/Commu...st_box_example

  10. #10
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: List Box Problem

    Hi vineet
    my code is as follows
    for creating listbox
    void Cview_list::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    iListBox = new (ELeave) CAknSingleNumberStyleListBox();//CAknSingleNumberStyleListBox(); // markableCEikTextListBox();//
    // Construct listbox
    iListBox->ConstructL(this, EAknListBoxSelectionList|EAknListBoxLoopScrolling );
    iListBox->SetContainerWindowL( *this );
    // Set scrollbars
    iListBox->CreateScrollBarFrameL( ETrue );
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );

    // Create listbox item array
    iListBoxItems = new (ELeave) CDesCArrayFlat(4);
    // Create listbox items

    iListBoxItems->AppendL( _L("0\tOneItem1\t") );
    iListBoxItems->AppendL( _L("0\ttwoItem2\t") );
    iListBoxItems->AppendL( _L("0\tthreeItem3\t") );
    iListBoxItems->AppendL( _L("0\tfourItem4\t") );
    //iListBox->SetCurrentItemIndex(1);
    // Add items to listbox
    iListBox->Model()->SetItemTextArray( iListBoxItems );
    // Listbox deletes the item array
    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
    iListBox->CreateScrollBarFrameL(ETrue);
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
    SetRect(aRect);
    ActivateL();


    and offerkey's part as follows
    TKeyResponse Cview_list::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    {

    if(aType != EEventKey)
    {
    return EKeyWasNotConsumed;
    }
    switch(aKeyEvent.iCode)
    {
    case EKeyUpArrow:
    case EKeyDownArrow:
    {
    // Forward up and down key press events to the list box
    return iListBox->OfferKeyEventL( aKeyEvent, aType );
    }
    default:
    break;
    }
    return EKeyWasNotConsumed;
    }
    and i dont know what should i do??
    list box is created but i cant scroll it by down arrow key...

  11. #11
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,019

    Re: List Box Problem

    Did you added the view in which this listbox is created to stack inside the DoActivateL() ?


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

    iContainer = Cview_list::NewL(aRect, *this);
    iContainer->SetMopParent(this);
    AppUi()->AddToStackL(*this, iContainer);
    }

    or if you are activating this view directly from AppUi then:

    AddToStackL(iView); // where iView is Cview_list*iView

  12. #12
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: List Box Problem

    thanks its working...

  13. #13
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: List Box Problem

    hi vineet..

    I have 2 classes suppose
    class A and class b
    in class A..
    CDesCArrayFlat* iListBoxItems;
    and in class B..
    CDesCArrayFlat* iListBoxItems2;
    I want to copy iListBoxItems into iListBoxItems2..
    with some appended data..
    How can I do it...


    _LIT(x,"1\t");
    _LIT(y,"\t");
    TBuf<500> text;
    for(TInt i=0;i<4;i++)
    {
    text.Append(x);
    iListBoxItems->AppendL(text);
    iListBoxItems->AppendL( iappview->MyArray ->operator[](i));
    text.Append(y);
    iListBoxItems->AppendL(text);
    text.Append(y);
    }

  14. #14
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: List Box Problem

    But when I reach at
    iListBoxItems->AppendL( iappview->MyArray ->operator[](i));
    my program crashes....

  15. #15
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

    Re: List Box Problem

    Quote Originally Posted by nishantanindya View Post
    But when I reach at
    iListBoxItems->AppendL( iappview->MyArray ->operator[](i));
    my program crashes....
    You should see the panic code from here.

Posting Permissions

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