×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    May 2009
    Location
    Russia
    Posts
    73

    Unhappy CAknSingleStyleListBox problem

    I utillized these article http://wiki.forum.nokia.com/index.ph...simple_listbox but for me Listbox does not hatch simply white background, and on him from one side ScrollBar.

    This is my code:
    Code:
    private:
    	CAknSingleStyleListBox* iSingleListBox;
    Code:
    void Ctesting001AppView::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    	SetRect(aRect);
    	SetBlank();
    	ActivateL();
    
    	iSingleListBox = new (ELeave) CAknSingleStyleListBox();
    	iSingleListBox->ConstructL(this, EAknListBoxSelectionList); 
    	iSingleListBox->SetContainerWindowL(*this); 
        
    	iSingleListBox->CreateScrollBarFrameL(ETrue); 
    	iSingleListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
    	CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); 
    	
    	iSingleListBox->SetRect(Rect());
    	
    	CDesCArray *itemList = new (ELeave) CDesCArrayFlat(2);
    	
    	itemList->AppendL(_L("\tFirst item\t\t"));
    	itemList->AppendL(_L("\tSecond item\t\t"));
    	
    	iSingleListBox->Model()->SetItemTextArray(itemList); 
    	iSingleListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); 
    	
    	iSingleListBox->SetCurrentItemIndex(0);
    	iSingleListBox->SetFocus(ETrue);
    	iSingleListBox->HandleItemAdditionL();
    	
    	iSingleListBox->View()->SetListEmptyTextL( _L("No Data") );
    	
    	iSingleListBox->ActivateL();
    	iSingleListBox->DrawNow();
    	}

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,089

    Re: CAknSingleStyleListBox problem

    CreateWindowL();
    SetRect(aRect);
    SetBlank();
    ActivateL()
    ;



    from above call the ActivateL() after drawing of listbox not before it, as you are doing

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: CAknSingleStyleListBox problem

    You can check my old-school example in http://discussion.forum.nokia.com/fo...ad.php?t=92554

  4. #4
    Regular Contributor
    Join Date
    May 2009
    Location
    Russia
    Posts
    73

    Re: CAknSingleStyleListBox problem

    I tried everything and not a what did not change, moved placed and changed a code, but result former white background. Here code fully:
    Code:
    Ctesting001AppView* Ctesting001AppView::NewL(const TRect& aRect)
    	{
    	Ctesting001AppView* self = Ctesting001AppView::NewLC(aRect);
    	CleanupStack::Pop(self);
    	return self;
    	}
    
    Ctesting001AppView* Ctesting001AppView::NewLC(const TRect& aRect)
    	{
    	Ctesting001AppView* self = new (ELeave) Ctesting001AppView;
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    void Ctesting001AppView::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    	SetBlank(); //if I will clean this line that a background becomes transparent in general
    	
    	iSingleListBox = new (ELeave) CAknSingleStyleListBox();
    	iSingleListBox->ConstructL(this, EAknListBoxSelectionList); 
    	iSingleListBox->SetContainerWindowL(*this); 
        
    	iSingleListBox->CreateScrollBarFrameL(ETrue); 
    	iSingleListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
            CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); 
    	
    	iSingleListBox->View()->SetListEmptyTextL( _L("No Data") ); 
        
    	CDesCArray* itemList = static_cast<CDesCArray*> (iSingleListBox->Model()->ItemTextArray());
     
    	itemList->AppendL(_L("\tFirst item\t\t"));
    	itemList->AppendL(_L("\tSecond item\t\t"));
     
    /*	iSingleListBox->Model()->SetItemTextArray(itemList); 
    	iSingleListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);*/
     
    	iSingleListBox->SetCurrentItemIndex(0);
    	iSingleListBox->SetFocus(ETrue);
    	iSingleListBox->HandleItemAdditionL();
        
    	iSingleListBox->ActivateL();
    	iSingleListBox->DrawNow();
        
    	SetRect(aRect);
    	ActivateL();
    	DrawNow();
    	}
    
    TKeyResponse Ctesting001AppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    	{
    	return iSingleListBox->OfferKeyEventL(aKeyEvent, aType);
    	}
    
    Ctesting001AppView::Ctesting001AppView()
    	{
    	}
    
    Ctesting001AppView::~Ctesting001AppView()
    	{
    	}
    
    void Ctesting001AppView::SizeChanged()
    	{
    	iSingleListBox->SetRect(Rect());
    	DrawNow();
    	}
    
    void Ctesting001AppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    	{
    	CCoeControl::HandlePointerEventL(aPointerEvent);
    	}

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

    Re: CAknSingleStyleListBox problem

    hi have you putted the following in the BaseContructL() of you Appui class:

    BaseConstructL(CAknAppUi::EAknEnableSkin);

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: CAknSingleStyleListBox problem

    I can not see the CountComponentControls and ComponentControl methods. And I have doubts about SetBlank.

  7. #7
    Regular Contributor
    Join Date
    May 2009
    Location
    Russia
    Posts
    73

    Re: CAknSingleStyleListBox problem

    Once again =) . Now all shows but on any pressure of the button nothing takes a place. Here code:
    Code:
    class Ctesting001AppView : public CCoeControl
    	{
    public:
    	static Ctesting001AppView* NewL(const TRect& aRect);
    	static Ctesting001AppView* NewLC(const TRect& aRect);
    	virtual ~Ctesting001AppView();
    
    public:
    	virtual void SizeChanged();
    	virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
    	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
    	TInt CountComponentControls() const;
    	CCoeControl* ComponentControl( TInt aIndex ) const;
    
    protected:
    	void Draw( const TRect& aRect ) const;
    	
    private:
    	void ConstructL(const TRect& aRect);
    	Ctesting001AppView();
    
    	CAknSingleStyleListBox* iSingleListBox;
    	//RWsSession iWsSession;
    	//RWindowGroup iWinGroup;
        	};
    Code:
    Ctesting001AppView* Ctesting001AppView::NewL(const TRect& aRect)
    	{
    	Ctesting001AppView* self = Ctesting001AppView::NewLC(aRect);
    	CleanupStack::Pop(self);
    	return self;
    	}
    
    Ctesting001AppView* Ctesting001AppView::NewLC(const TRect& aRect)
    	{
    	Ctesting001AppView* self = new (ELeave) Ctesting001AppView;
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    void Ctesting001AppView::ConstructL(const TRect& aRect)
    	{
    /*	iWsSession = iEikonEnv->WsSession();
    	
    	iWinGroup = RWindowGroup(iWsSession);
    	iWinGroup.Construct((TUint32)&iWinGroup);
    	iWinGroup.SetOrdinalPosition(1, ECoeWinPriorityAlwaysAtFront);
    	iWinGroup.EnableReceiptOfFocus(ETrue);
    	iWinGroup.SetNonFading(ETrue);
    	CreateWindowL(&iWinGroup);*/
    	CreateWindowL();
    	//SetBlank(); //if I will clean this line that a background becomes transparent in general
    	
    	iSingleListBox = new (ELeave) CAknSingleStyleListBox();
    	iSingleListBox->ConstructL(this, EAknListBoxSelectionList); 
    	iSingleListBox->SetContainerWindowL(*this); 
    
    	iSingleListBox->CreateScrollBarFrameL(ETrue); 
    	iSingleListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
            CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); 
    	
    	iSingleListBox->View()->SetListEmptyTextL( _L("No Data") ); 
        
    	CDesCArray* itemList = static_cast<CDesCArray*> (iSingleListBox->Model()->ItemTextArray());
     
    	itemList->AppendL(_L("\tFirst item\t\t"));
    	itemList->AppendL(_L("\tSecond item\t\t"));
     
    /*	iSingleListBox->Model()->SetItemTextArray(itemList); 
        iSingleListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);*/
     
        //iSingleListBox->SetCurrentItemIndex(0);
    	iSingleListBox->SetFocus(ETrue);
    	iSingleListBox->HandleItemAdditionL();
        
    	iSingleListBox->ActivateL();
    	iSingleListBox->DrawNow();
        
    	SetRect(aRect);
        ActivateL();
        DrawNow();
    	}
    
    TInt Ctesting001AppView::CountComponentControls() const
    	{
    	return 1;
    	}
    
    CCoeControl* Ctesting001AppView::ComponentControl( TInt aIndex ) const
    	{
    	switch ( aIndex )
    		{
    	case 0:
    		return iSingleListBox;
    		}
    	return NULL;
    	}
    
    TKeyResponse Ctesting001AppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    	{
    	if ( iSingleListBox->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
    		{
    		return EKeyWasConsumed;
    		}
    	return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
    	}
    
    void Ctesting001AppView::Draw( const TRect& aRect ) const
    	{
    	CWindowGc& gc = SystemGc();
    	gc.Clear( aRect );
    	}
    Ctesting001AppView::Ctesting001AppView()
    	{
    	}
    
    Ctesting001AppView::~Ctesting001AppView()
    	{
    	}
    
    void Ctesting001AppView::SizeChanged()
    	{
    	iSingleListBox->SetRect(Rect());
    	DrawNow();
    	}
    
    void Ctesting001AppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    	{
    	CCoeControl::HandlePointerEventL(aPointerEvent);
    	}

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: CAknSingleStyleListBox problem

    Your control seems to be complete then.
    Make sure that you add it to the Control Stack: AddToStackL (in the AppUi, usually in ConstructL - and RemoveFromStack in its destructor)

  9. #9
    Regular Contributor
    Join Date
    May 2009
    Location
    Russia
    Posts
    73

    Re: CAknSingleStyleListBox problem

    wizard_hu_, many thanks. Now I understood how to create GUI with Avkon

Similar Threads

  1. Problem with CAknDoubleStyleListBox with a CAknSearchField
    By jjig in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-09-17, 00:58
  2. [moved] CAknSingleStyleListBox problem
    By aktarjahan2003 in forum Symbian User Interface
    Replies: 5
    Last Post: 2008-10-29, 09:26
  3. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  4. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  5. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

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