"Constructing Listbox from Resource"- problem

Login to reply to this topic.
Tue, 2007-02-06 11:14
Joined: 2007-02-05
Forum posts: 5
Hi,
I hav been trying the listbox construction from quite some time but no use.
i dnt get any comple-time or runtime error but am unable to c the listbox.
hav seen SDK help,all forum helps n use the same code  but no help.

my container class' code is as follows:

#include <aknlists.h>
#include <barsread.h>
#include <avkon.hrh>
void Csh_listAppView::ConstructL(const TRect& aRect)
    {
    // Create a window for this application view
    CreateWindowL();

   // Set the windows size
    SetRect(aRect);
       
    list = new (ELeave) CAknSingleStyleListBox;
   
    //list->ConstructL(this);
   
    list->SetContainerWindowL(*this);
           
    TResourceReader rr;
     iCoeEnv->CreateResourceReaderLC(rr,R_SS_LIST_TRY);
     list->ConstructFromResourceL(rr);
   
    CleanupStack::PopAndDestroy();
   
   
    SizeChanged();
    list->ActivateL();
    DrawNow();
     
       
    // Activate the window, which makes it ready to be drawn
    ActivateL();
    MakeVisible(ETrue);
   
    }

My resorce file:

RESOURCE LISTBOX R_SS_LIST_TRY
{
   array_id = R_SS_LIST_TRY_ITEMS;
   flags = EAknListBoxSelectionList;
}

RESOURCE ARRAY R_SS_LIST_TRY_ITEMS
{
   items =
   {
      LBUF { txt = "\titem1\t0\t1"; },
      LBUF { txt = "\titem2\t0\t1"; },
      LBUF { txt = "\titem3\t0\t1"; }
   };
}

Do help me if anyone finds any solution

Tue, 2007-02-06 15:13
Joined: 2004-12-09
Forum posts: 78
Re: "Constructing Listbox from Resource"- problem
What are you doing in the SizeChanged Method ? Are you calling SetRect on list box. You have to set the list box size before it becomes visible.
Wed, 2007-02-07 06:13
Joined: 2007-02-05
Forum posts: 5
Re: "Constructing Listbox from Resource"- problem
I am not doing anything in SizeChanged().i'l try to implement it now but i did try this also:

list->SetRect(aRect);

do v need to specify certain size as well?
Wed, 2007-02-07 07:22
Joined: 2005-08-11
Forum posts: 278
Re: "Constructing Listbox from Resource"- problem
Put SetEXtent in your SizeChanged function 

eg:

void Csh_listAppView::SizeChanged()
    { 
    list->SetExtent (TPoint(0,0), list->MinimumSize());
    }
Wed, 2007-02-07 11:37
Joined: 2007-02-05
Forum posts: 5
Re: "Constructing Listbox from Resource"- problem
I have already implemented SizeChanged() and used SetExtent( TPoint(0,0), list->MinimumSize())
but now i m getting run-time error..."App-Closed ".
hav been strugling over frm quite sum time but no luck Sad
Wed, 2007-02-07 12:16
Joined: 2005-08-11
Forum posts: 278
Re: "Constructing Listbox from Resource"- problem
for me this works fine:

iListBox = new( ELeave ) CAknSingleStyleListBox();
iListBox->ConstructL( this, EAknListBoxSelectionList);
iListBox->CreateScrollBarFrameL(ETrue);

//add the items to the list

iAvkonAppUi->AddToStackL(iListBox);

iListBox->ActivateL();
iListBox->DrawNow();
SetRect(aRect);
ActivateL();
//no need to call SizeChanged
Thu, 2007-02-08 12:33
Joined: 2007-02-05
Forum posts: 5
Re: "Constructing Listbox from Resource"- problem
I am deriving my contaner class from CCoeControl and appui class from CAknAppUi so how can i use
" iAvkonAppUi->AddToStackL(iListBox);" ?
  • Login to reply to this topic.