×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    what is the problem with this code?

    good morning,

    i want to create an CAknSingleGraphicStyleListBox and using the following code:

    CTextListBoxModel* model = iSimpleListBox->Model(); // not taking ownership
    model->SetOwnershipType (ELbmOwnsItemArray);
    iListBoxItems = static_cast<CDesC16Array*>(iSimpleListBox->Model()->ItemTextArray());
    iListBoxItems = new (ELeave) CDesCArrayFlat(3);

    iListBoxItems->AppendL(_L("0\tItem 1"));
    iListBoxItems->AppendL(_L("1\tItem 2"));
    iListBoxItems->AppendL(_L("2\tItem 3"));
    CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray(2);
    CleanupStack::PushL( icons );
    icons->AppendL(iEikonEnv->CreateIconL(KFilePath,EMbmCountapplicationsws6Myicon1,EMbmCountapplicationsws6Myicon1_mask));
    iSimpleListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
    CleanupStack::PopAndDestroy();

    the applications doesn't gives any error but it does not displays the list... the text "No Data" gets displayed on the view....

    does anybody has solution??

    thanks in advance

  2. #2
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    Re: what is the problem with this code?

    Hi,

    Add these lines after adding ListBox Items.

    iSimpleListBox->Model()->SetItemTextArray( iListBoxItems);
    iSimpleListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );

    Regards
    Asif Nazir

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    thanks for ur reply Nazir,

    do u think the code otherwise is ok?
    because it is now giving error kern exec 3

    plz help..

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: what is the problem with this code?

    do not call CleanupStack::PopAndDestroy(); for the icons, just call CleanupStack::Pop(); and the Kern Exec should also go away.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    thanks for the reply sir i will just check this..

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: what is the problem with this code?

    Hello,

    there might be also problem that you are adding only one icon to the array, while you are in the text reference icons on indexes 0, 1 and 2, but I think this is not reason to crash the app.

    Those lines also do not make sense:
    iListBoxItems = static_cast<CDesC16Array*>(iSimpleListBox->Model()->ItemTextArray());
    iListBoxItems = new (ELeave) CDesCArrayFlat(3);

    Why you are obtaining the pointer, while later you are creating the array?

    Here I cut&paste from my code how I create the listbox - you cannot use it directly, but as a clue how to correclty proceed:
    ================================================
    // Create listbox
    iListBox = new( ELeave ) CAknSingleLargeStyleListBox();
    iListBox->ConstructL( this, EAknListBoxSelectionList );

    // Create icon array
    CArrayPtrFlat<CGulIcon>* icons =new( ELeave ) CArrayPtrFlat<CGulIcon>(1);
    CleanupStack::PushL(icons);

    // Load icons from mif file into icon array
    CGulIcon* icon = NULL;
    icon = CClientUtils::AknLoadMifIconL( KGfxFileName, EMbmMsttuiSettingstt );
    CleanupStack::PushL( icon );
    icons->AppendL( icon );
    CleanupStack::Pop( icon );

    icon = CClientUtils::AknLoadMifIconL( KGfxFileName, EMbmMsttuiSettingsgeneral );
    CleanupStack::PushL( icon );
    icons->AppendL( icon );
    CleanupStack::Pop( icon );

    // Set icon array to listbox (the ownership is automatically transferred)
    iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    CleanupStack::Pop(icons);

    // Setup text array
    CDesCArrayFlat* texts = new(ELeave)CDesCArrayFlat(1);
    CleanupStack::PushL(texts);
    texts->AppendL( _L("0\tTime table") );
    texts->AppendL( _L("1\tGeneral") );
    CleanupStack::Pop(texts);

    // Set text array to listobox and mark it as owned by listbox
    iListBox->Model()->SetItemTextArray(texts);
    iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);

    // Create scrollbars
    iListBox->CreateScrollBarFrameL( ETrue );
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

    // Set rectangle
    iListBox->SetRect(Rect());

    // Append listbox amog other controls
    User::LeaveIfError( iControls.Append( iListBox ) );

    // Actrivate listbox
    iListBox->ActivateL();
    ================================================
    Regards,
    STeN

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    sorry but its still giving same error and now my code in ConstructL() is as follows:

    CreateWindowL(); iSimpleListBox->SetListBoxObserver(this);
    CreateListL();
    CDesCArray *itemList= new (ELeave) CDesCArrayFlat(2);
    itemList->AppendL(_L("0\tFlight Details"));
    itemList->AppendL(_L("1\tRing Tones"));

    iSimpleListBox->Model()->SetItemTextArray( iListBoxItems);
    iSimpleListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );

    iSimpleListBox->Model()->SetItemTextArray(itemList); iSimpleListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
    CArrayPtr<CGulIcon> *icons=new(ELeave)CAknIconArray(1);
    CleanupStack::PushL( icons );

    icons->AppendL( iEikonEnv->CreateIconL( KFilePath,EMbmCountapplicationsws6Myicon1,EMbmCountapplicationsws6Myicon1_mask) );

    iSimpleListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    CleanupStack::Pop();
    iSimpleListBox->HandleItemAdditionL();
    iSimpleListBox->SetFocus( ETrue );
    iSimpleListBox->SetRect(aRect);
    ActivateL();

    code for CreateList() is :

    iSimpleListBox = new(ELeave)CAknSingleGraphicStyleListBox();
    iSimpleListBox->SetContainerWindowL(*this);
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SIMPLELIST_SLISTBOX);
    iSimpleListBox->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy();

    now did u find any problem???

  8. #8
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    thank u very much Sten

    i really appreciate ur help..

    thanks..

  9. #9
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    hi Stenlin

    one more thing, wat is the type of iControls.

  10. #10
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: what is the problem with this code?

    Hi,

    this is array of controls - it is not necessary to be used - it just to make the code more transparent.

    Definiton:
    RPointerArray<CCoeControl> iControls;

    and then I use it when I implement CCoeControl virtual methods:

    // ------------------------------------------------
    //
    // Controls count
    //
    // ------------------------------------------------
    TInt CContainer::CountComponentControls() const
    {
    return iControls.Count();
    }

    // ------------------------------------------------
    //
    // Get control
    //
    // ------------------------------------------------
    CCoeControl* CContainer::ComponentControl(TInt aIndex) const
    {
    if ( aIndex < iControls.Count() && aIndex > -1 )
    return iControls[aIndex];

    return NULL;
    }

    Regards,
    STeN

  11. #11
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    ok i have implemented the list and there is no error now but the list is not getting displayed...don't know why?
    the code is implemented in CreateListL() and this function i am calling in ConstructL()

    plz see the code below:

    iSimpleListBox = new( ELeave ) CAknSingleGraphicStyleListBox();
    iSimpleListBox->ConstructL( this, EAknListBoxSelectionList );

    // Create icon array
    CArrayPtrFlat<CGulIcon>* icons =new( ELeave ) CArrayPtrFlat<CGulIcon>(1);
    CleanupStack::PushL(icons);

    icons->AppendL(iEikonEnv->CreateIconL(KFilePath,EMbmCountapplicationsws6Myicon1,EMbmCountapplicationsws6Myicon1_mask));

    // Set icon array to listbox (the ownership is automatically transferred)
    iSimpleListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    //CleanupStack::Pop(icons);

    // Setup text array
    CDesCArrayFlat* texts = new(ELeave)CDesCArrayFlat(1);
    CleanupStack::PushL(texts);
    texts->AppendL( _L("0\tTime table") );
    texts->AppendL( _L("1\tGeneral") );
    CleanupStack::Pop(texts);

    // Set text array to listobox and mark it as owned by listbox
    iSimpleListBox->Model()->SetItemTextArray(texts);
    iSimpleListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);

    // Create scrollbars
    iSimpleListBox->CreateScrollBarFrameL( ETrue );
    iSimpleListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
    CleanupStack::Pop( icons );
    iSimpleListBox->SetFocus(ETrue);

  12. #12
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    just a blank view gets displayed...

  13. #13
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: what is the problem with this code?

    Hi,

    did you implement CountComponentControls() and ComponentControl() methods?

    STeN

  14. #14
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: what is the problem with this code?

    yes i have implemented both of them and i think are correct..

    see:

    TInt CInstalledAppsContainer::CountComponentControls() const
    {
    return 1;
    }
    CCoeControl* CInstalledAppsContainer::ComponentControl( TInt aIndex ) const
    {
    switch (aIndex)
    {
    case 0:
    return iSimpleListBox;
    default:
    return NULL;
    }
    }

    anything else..

  15. #15
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: what is the problem with this code?

    Hi,

    1/ Did you call iListBox::SetRect() and iListBox::ActivateL() method?
    2/ Do you have following code in the container ConstructL()?

    CreateWindowL();
    SetRect( aRect );

    // Code to create and activate listbox
    ...

    ActivateL();

    3/ Is your container really derived from CCoeControl?
    4/ Check if your container does not have Draw() method, which clears the view

    Regards,
    STeN

Similar Threads

  1. Problem running code at www.mobilenin.com
    By nick_santa83 in forum Symbian
    Replies: 5
    Last Post: 2007-12-27, 07:10
  2. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  3. Replies: 3
    Last Post: 2007-01-18, 11:27
  4. run this code & try to figure out the problem
    By mariam nasif in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2005-03-15, 20:08
  5. Replies: 0
    Last Post: 2004-04-06, 06:09

Posting Permissions

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