×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61

    Weird problem with listbox and scrolling indicator

    Hi all,

    Got a bit of a problem. Was playing around with listboxes and created a CAknSingleNumberStyleListBox, which I got to work quite nicely, but then I decided to try out CAknDoubleNumberStyleListBox, and here's where I bumped into the problem. It works fine, apart from the scoll indicators which are nowhere to be seen.

    The only thing I changed was the class I use for the listbox (and the formatting of the items of course).

    I call CreateScrollBarFrameL() and SetScrollBarVisibilityL() as normal, and I call SetMopParent() when creating my container. Anyone got any ideas what could be missing?

    If I switch back to CAknSingleNumberStyleListBox the scroll indicators appear again. Is the double style one a special case or something?

    I'd be grateful for any help.

    Cheers,
    Bjorn Rudolfsson

  2. #2
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Braunschweig, Germany
    Posts
    345
    The scrollbars are a bit tricky. It is important that you call the functions to create the listbox in the right order:

    iListBox = new( ELeave ) AknSingleStyleListBox();
    iListBox->SetContainerWindowL(*this);
    iListBox->SetMopParent(this);
    iListBox->ConstructL( this, EAknListBoxSelectionList);

    iListBox->CreateScrollBarFrameL();
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);

    You have to call SetMopParent *before* you call ConstructL and before you addthe scrollbars.

    It is also important that you call SetMopParent for the container as well.

    Regards,
    Bernd

  3. #3
    Registered User
    Join Date
    Mar 2003
    Location
    Linköping, Sweden
    Posts
    11
    Hi,
    You should also call iListBox->UpdateScrollBarsL();

    I had the same problem until I found that method atleast :-)

    /Hans

  4. #4
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61

    Doesn't seem to work...

    Thanks for the help guys, but it still doesn't seem to work I'm afraid. Tried calling both SetMopParent() and UpdateScrollBarsL(),
    but still no scroll indicators. Here's the code. As far as I can see it should work fine, but maybe I've missed something:

    iListbox = new (ELeave) CAknDoubleNumberStyleListBox;
    iListbox->SetContainerWindowL(*this);
    iListbox->SetMopParent(this);

    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC(reader, R_SIMPLE_LISTBOX);
    iListbox->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy(); // reader

    CDesCArray* array = new (ELeave) CDesCArrayFlat(8);
    CleanupStack::PushL(array);
    array->AppendL(_L("1\tFirst\tItem one"));
    array->AppendL(_L("2\tSecond\tItem two"));
    array->AppendL(_L("3\tThird\tItem three"));
    array->AppendL(_L("4\tFourth\tItem four"));
    array->AppendL(_L("5\tFifth\tItem five"));
    array->AppendL(_L("6\tSixth\tItem six"));
    array->AppendL(_L("7\tSeventh\tItem seven"));
    array->AppendL(_L("8\tEighth\tItem eight"));
    CleanupStack::Pop();
    iListbox->Model()->SetItemTextArray(array);

    iListbox->CreateScrollBarFrameL(ETrue);
    iListbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
    iListbox->UpdateScrollBarsL();

    iListbox->SetListBoxObserver(this);
    iListbox->SetRect(Rect());

    Any thoughts? The only thing I can think of is that maybe some of the functions need to be called in different order, but I've tried a bunch of combinations already, including creating the scrollbar before adding the items and after SetRect(). Ah well, nothing is ever simple is it? :-)

    Cheers,
    Bjorn

  5. #5
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Braunschweig, Germany
    Posts
    345
    I assume that your listbox is in some kind of container which is created in the AppUi class or a view class.

    In this class you also have to do something like this:

    iContainer = new (ELeave) CYourContainerClass();
    iContainer->SetMopParent(this);
    iContainer->ConstructL(... whatever ...);

    If you don't set the MopParents from the elemet that owns the area where the scroll indicators are painted down to the ListBox, you will never get the Scrollbars.

    Regards,
    Bernd

  6. #6
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61
    Yep, the code is from the ConstructL() of my container class, which is instantiated in my AppUi class, and yes, I do call SetMopParent() on the container class just as in your example.

    And that's the bugger, it should work shouldn't it? It does seem to work for some listbox classes. In fact, by the looks of it single style listboxes do not seem to have any problems with the scroll indicators. I get them to display even without calling SetMopParent() and UpdateScrollBarsL() on the listbox, but as soon as I change to a double style list, poof! the scroll indicators are no more.

    Cheers,
    Bjorn

  7. #7
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Braunschweig, Germany
    Posts
    345
    As far as I can see it should work. I do nearly the same think and it works for me.

    I always do a
    iListBox->HandleItemAdditionL();
    after adding the items to the lisbox. That is the only difference I see between your code and mine.

    Regards,
    Bernd

  8. #8
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61
    No, that doesn't seem to work either :-(

    Ok, thanks for your help anyway. I'll keep on trying.

    Cheers,
    Bjorn

  9. #9
    Registered User
    Join Date
    May 2004
    Posts
    33
    Hi,
    I've the same kind of problem with a DoubleStyleListBox. I can't see the scrollbar.
    I tried to follow the directions of this thread, but the problem remains.
    Did you find a solution?
    Thanks

    Regards
    Matteo

  10. #10
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61
    Afraid not. Tried everything I could think of, but no luck so far.

    Cheers,
    Bjorn

  11. #11
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    hi

    Have you tried calling the setmop parent also for the container in which your listbox is in. I.e. inside your view class for example. And then not calling the set mop parent for the listbox.

    yucca

  12. #12
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61
    Yup, tried that as well.

    Cheers,
    Bjorn

  13. #13
    Registered User
    Join Date
    Apr 2004
    Location
    Karlsruhe,Germany
    Posts
    8

    got solution :-)))

    Hi listbox specialists,

    The problem is that the SetMopParent() in the AppUi is called after the listbox has been constructed. I have two solutions that worked for me:

    1.) call SetMopParent() for the container inside ConstructL() of the view:
    void CHelloWorldAppView::ConstructL(const TRect& aRect)
    {
    // Create a window for this application view
    CreateWindowL();
    SetMopParent(iEikonEnv->EikAppUi());

    iListBox = new( ELeave ) CAknDoubleStyleListBox();
    iListBox->SetContainerWindowL(*this);
    ...

    2.) call SetRect() in ConstructL() of the AppUi:
    void CHelloWorldAppUi::ConstructL()
    {
    BaseConstructL();

    iAppView = CHelloWorldAppView::NewL(ClientRect());

    iAppView->SetMopParent(this);

    iAppView->SetRect(ClientRect());

    AddToStackL(iAppView);
    }

    thomas

Posting Permissions

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