×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    34

    A ListBox problem, well-skilled developer please help me

    I met a problem about inserting an item to a ListBox with icons.

    After I opened and converted an jpg file to a *CFbsBitmap, and set it to CGulIcon, then I inserted this CGulIcon to ListBox's icons array. But after this two icons of the ListBox were changed, not one! Could someone who knows this reason help me? My code is just like this:

    //--------------------------------------------------
    // 1. the text of ListBox
    CDesCArray* listboxArray = STATIC_CAST(CDesCArray*, iListBox->Model()->ItemTextArray() );
    CleanupStack::PushL( listboxArray );

    TBuf<50> tListItem;
    tListItem.Append(_L("1\FirstLine\tSecondLine"));
    listboxArray->InsertL(1,tListItem);//insert an item at pos 2

    // 2. Add this item
    iListBox->HandleItemAdditionL();
    CleanupStack::Pop(); // listboxArray

    // 3. use .jpg file as icons on ListBox
    CGulIcon* myIcon = CGulIcon::NewL();
    CleanupStack::PushL( myIcon );
    myIcon->SetBitmap( iBitmapJpg ); //iBitmapJpg is a *CFbsBitmap
    icons->InsertL( 1, myIcon ); //insert an icon at pos 2

    iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);

    CleanupStack::Pop();//myIcon
    // end.
    //

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    194

    RE: A ListBox problem, well-skilled developer please help me

    The first column should be integer represented in text (pointing to which icon in IconArray).

    You should modify the code as follows:
    tListItem.Append(_L("0\FirstLine\tSecondLine"));

    Regards,

    Nani

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    224

    Converting JPEG to Bitmap

    Hi folks, There are code fragments in the following for inserting bitmap icon. I guess that it is the problem with SetBitmap() method. It is crasing when I try to run the program. It would be very much appreciable to get your comments on it.

    CArrayPtr<CGulIcon>* icons =
    new( ELeave ) CArrayPtrFlat<CGulIcon>(256);
    CleanupStack::PushL( icons );


    CGulIcon* myIcon = CGulIcon::NewL();
    CleanupStack::PushL( myIcon );
    myIcon->SetBitmap(iBitmap); //iBitmap is a *CFbsBitmap
    //It is crashing when I try to set iBitmap object.

    icons->InsertL( 0, myIcon );

    aListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
    CleanupStack::Pop(); //myIcon
    CleanupStack::Pop();

Posting Permissions

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