×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    37

    SetTextL doesn't work!

    hi there,

    I've got a Label in my simple UI application, when I call SetTextL of the Label at run time, nothing changes!!
    here you are my code :

    Code:
    void CTestUIContainer::setStatus(const TDesC& value){
    	iLabel1->SetTextL(value);
    }
    And I call the above method from the CtestUIContainerView::HandleCommandL when a menu get selected as code below :

    Code:
    iTestUIContainer->setStatus(_L("Waiting..."));
    by the way when I put the changing label code at the following method which runs at the initiate loading, it works:


    Code:
    void CTestUIContainer::LayoutControls()
    	{
    	iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    	iLabel1->SetTextL(_L("Started..."));
    	}

    does anyone know what is wrong with my code? :(

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

    Re: SetTextL doesn't work!

    Try calling DrawNow() after changing the value.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    37

    Re: SetTextL doesn't work!

    Thanks for your prompt reply,

    I have changed my code to the following one :

    Code:
    void CTestUIContainer::setStatus(const TDesC& value){
    	iLabel1->SetTextL(value);
    	DrawNow();
    }
    but doesn't work again... :(

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

    Re: SetTextL doesn't work!

    Are you implementing the Count components etc. functions in the CTestUIContainer. so the system would know how many controls there are inside the container, and would also be able to get pointers for them to get them drawn correctly ?

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

    Re: SetTextL doesn't work!

    how about this:

    Code:
    void CTestUIContainer::setStatus(const TDesC& value){
    iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    	iLabel1->SetTextL(value);
    	DrawNow();
    }

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

    Re: SetTextL doesn't work!

    should not really help if ComponentControl(TInt) & CountComponentControls() functions are not implemented in the container.

  7. #7
    Registered User
    Join Date
    Oct 2010
    Posts
    37

    Re: SetTextL doesn't work!

    It doesn't work either :(((((

    Quote Originally Posted by vineet.jain View Post
    how about this:

    Code:
    void CTestUIContainer::setStatus(const TDesC& value){
    iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    	iLabel1->SetTextL(value);
    	DrawNow();
    }

  8. #8
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,078

    Re: SetTextL doesn't work!

    Quote Originally Posted by symbianyucca View Post
    should not really help if ComponentControl(TInt) & CountComponentControls() functions are not implemented in the container.
    but i think the label wouldn't be visible first time as well if these functions are not implemented.

  9. #9
    Registered User
    Join Date
    Oct 2010
    Posts
    37

    Re: SetTextL doesn't work!

    Quote Originally Posted by symbianyucca View Post
    should not really help if ComponentControl(TInt) & CountComponentControls() functions are not implemented in the container.
    yes, I've got the mentioned methods in Container :

    Code:
    /**
    * Return the number of controls in the container (override)
    * @return count
    */
    TInt CTestUIContainer::CountComponentControls() const
    	{
    	return ( int ) ELastControl;
    	}
    				
    /**
    * Get the control with the given index (override)
    * @param aIndex Control index [0...n) (limited by #CountComponentControls)
    * @return Pointer to control
    */
    CCoeControl* CTestUIContainer::ComponentControl( TInt aIndex ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	switch ( aIndex )
    		{
    		case ELabel1:
    			return iLabel1;
    		}
    	// ]]] end generated region [Generated Contents]
    	
    	// handle any user controls here...
    	
    	return NULL;
    	}

  10. #10
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,078

    Re: SetTextL doesn't work!

    have you implemented the SizeChanged() method ?

  11. #11
    Registered User
    Join Date
    Oct 2010
    Posts
    37

    Re: SetTextL doesn't work!

    Quote Originally Posted by vineet.jain View Post
    have you implemented the SizeChanged() method ?
    yap mate, I've done it too , here you are the complete code of Container (It's been generated by UI designer):

    Code:
    /*
    ========================================================================
     Name        : testUIContainer.cpp
     Author      : 
     Copyright   : Your copyright notice
     Description : 
    ========================================================================
    */
    // [[[ begin generated region: do not modify [Generated System Includes]
    #include <barsread.h>
    #include <stringloader.h>
    #include <eiklabel.h>
    #include <eikenv.h>
    #include <aknviewappui.h>
    #include <eikappui.h>
    #include <testUI.rsg>
    // ]]] end generated region [Generated System Includes]
    
    // [[[ begin generated region: do not modify [Generated User Includes]
    #include "testUIContainer.h"
    #include "testUIContainerView.h"
    #include "testUI.hrh"
    #include "testUIContainer.hrh"
    // ]]] end generated region [Generated User Includes]
    
    // [[[ begin generated region: do not modify [Generated Constants]
    // ]]] end generated region [Generated Constants]
    
    /**
     * First phase of Symbian two-phase construction. Should not 
     * contain any code that could leave.
     */
    CTestUIContainer::CTestUIContainer()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	iLabel1 = NULL;
    	// ]]] end generated region [Generated Contents]
    	
    	}
    /** 
     * Destroy child controls.
     */
    CTestUIContainer::~CTestUIContainer()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	delete iLabel1;
    	iLabel1 = NULL;
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    /**
     * Construct the control (first phase).
     *  Creates an instance and initializes it.
     *  Instance is not left on cleanup stack.
     * @param aRect bounding rectangle
     * @param aParent owning parent, or NULL
     * @param aCommandObserver command observer
     * @return initialized instance of CTestUIContainer
     */
    CTestUIContainer* CTestUIContainer::NewL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CTestUIContainer* self = CTestUIContainer::NewLC( 
    			aRect, 
    			aParent, 
    			aCommandObserver );
    	CleanupStack::Pop( self );
    	return self;
    	}
    
    /**
     * Construct the control (first phase).
     *  Creates an instance and initializes it.
     *  Instance is left on cleanup stack.
     * @param aRect The rectangle for this window
     * @param aParent owning parent, or NULL
     * @param aCommandObserver command observer
     * @return new instance of CTestUIContainer
     */
    CTestUIContainer* CTestUIContainer::NewLC( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CTestUIContainer* self = new ( ELeave ) CTestUIContainer();
    	CleanupStack::PushL( self );
    	self->ConstructL( aRect, aParent, aCommandObserver );
    	return self;
    	}
    			
    /**
     * Construct the control (second phase).
     *  Creates a window to contain the controls and activates it.
     * @param aRect bounding rectangle
     * @param aCommandObserver command observer
     * @param aParent owning parent, or NULL
     */ 
    void CTestUIContainer::ConstructL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	if ( aParent == NULL )
    	    {
    		CreateWindowL();
    	    }
    	else
    	    {
    	    SetContainerWindowL( *aParent );
    	    }
    	iFocusControl = NULL;
    	iCommandObserver = aCommandObserver;
    	InitializeControlsL();
    	SetRect( aRect );
    	ActivateL();
    	// [[[ begin generated region: do not modify [Post-ActivateL initializations]
    	// ]]] end generated region [Post-ActivateL initializations]
    	
    	}
    			
    /**
    * Return the number of controls in the container (override)
    * @return count
    */
    TInt CTestUIContainer::CountComponentControls() const
    	{
    	return ( int ) ELastControl;
    	}
    				
    /**
    * Get the control with the given index (override)
    * @param aIndex Control index [0...n) (limited by #CountComponentControls)
    * @return Pointer to control
    */
    CCoeControl* CTestUIContainer::ComponentControl( TInt aIndex ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	switch ( aIndex )
    		{
    		case ELabel1:
    			return iLabel1;
    		}
    	// ]]] end generated region [Generated Contents]
    	
    	// handle any user controls here...
    	
    	return NULL;
    	}
    				
    /**
     *	Handle resizing of the container. This implementation will lay out
     *  full-sized controls like list boxes for any screen size, and will layout
     *  labels, editors, etc. to the size they were given in the UI designer.
     *  This code will need to be modified to adjust arbitrary controls to
     *  any screen size.
     */				
    void CTestUIContainer::SizeChanged()
    	{
    	CCoeControl::SizeChanged();
    	LayoutControls();
    	// [[[ begin generated region: do not modify [Generated Contents]
    			
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    // [[[ begin generated function: do not modify
    /**
     * Layout components as specified in the UI Designer
     */
    void CTestUIContainer::LayoutControls()
    	{
    	iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    	iLabel1->SetTextL(_L("Started..."));
    	}
    // ]]] end generated function
    
    void CTestUIContainer::setStatus(const TDesC& value){
    	iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    	iLabel1->SetTextL(value);
    	DrawNow();
    }
    /**
     *	Handle key events.
     */				
    TKeyResponse CTestUIContainer::OfferKeyEventL( 
    		const TKeyEvent& aKeyEvent, 
    		TEventCode aType )
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	
    	// ]]] end generated region [Generated Contents]
    	
    	if ( iFocusControl != NULL
    		&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
    		{
    		return EKeyWasConsumed;
    		}
    	return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
    	}
    				
    // [[[ begin generated function: do not modify
    /**
     *	Initialize each control upon creation.
     */				
    void CTestUIContainer::InitializeControlsL()
    	{
    	iLabel1 = new ( ELeave ) CEikLabel;
    	iLabel1->SetContainerWindowL( *this );
    		{
    		TResourceReader reader;
    		iEikonEnv->CreateResourceReaderLC( reader, R_TESTUICONTAINER_LABEL1 );
    		iLabel1->ConstructFromResourceL( reader );
    		CleanupStack::PopAndDestroy(); // reader internal state
    		}
    	
    	}
    // ]]] end generated function
    
    /** 
     * Handle global resource changes, such as scalable UI or skin events (override)
     */
    void CTestUIContainer::HandleResourceChange( TInt aType )
    	{
    	CCoeControl::HandleResourceChange( aType );
    	SetRect( iAvkonViewAppUi->View( TUid::Uid( ETestUIContainerViewId ) )->ClientRect() );
    	// [[[ begin generated region: do not modify [Generated Contents]
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    /**
     *	Draw container contents.
     */				
    void CTestUIContainer::Draw( const TRect& aRect ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	CWindowGc& gc = SystemGc();
    	gc.Clear( aRect );
    	
    	// ]]] end generated region [Generated Contents]
    	
    	}

  12. #12
    Registered User
    Join Date
    Oct 2010
    Posts
    37

    Re: SetTextL doesn't work!

    I've found a point,

    just after changing the label I place a socket accept implementation :

    Code:
    			iTestUIContainer->setStatus(_L("Waiting..."));
    
    			RSocket acceptSock;
    			User::LeaveIfError(acceptSock.Open(iSocketServ));
    			iSocket->Accept(acceptSock, aStatus);
    			User::WaitForRequest(aStatus);
    :

    when I remove the socket part(the red part), it works correctly and change the label, any clue why it behaves this way??!!! and why i cannot change the label when I am waiting for a incoming socket???!!!

  13. #13
    Regular Contributor
    Join Date
    Apr 2010
    Posts
    131

    Re: SetTextL doesn't work!

    Quote Originally Posted by asadi.alireza View Post
    yap mate, I've done it too , here you are the complete code of Container (It's been generated by UI designer):

    Code:
    /*
    ========================================================================
     Name        : testUIContainer.cpp
     Author      : 
     Copyright   : Your copyright notice
     Description : 
    ========================================================================
    */
    // [[[ begin generated region: do not modify [Generated System Includes]
    #include <barsread.h>
    #include <stringloader.h>
    #include <eiklabel.h>
    #include <eikenv.h>
    #include <aknviewappui.h>
    #include <eikappui.h>
    #include <testUI.rsg>
    // ]]] end generated region [Generated System Includes]
    
    // [[[ begin generated region: do not modify [Generated User Includes]
    #include "testUIContainer.h"
    #include "testUIContainerView.h"
    #include "testUI.hrh"
    #include "testUIContainer.hrh"
    // ]]] end generated region [Generated User Includes]
    
    // [[[ begin generated region: do not modify [Generated Constants]
    // ]]] end generated region [Generated Constants]
    
    /**
     * First phase of Symbian two-phase construction. Should not 
     * contain any code that could leave.
     */
    CTestUIContainer::CTestUIContainer()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	iLabel1 = NULL;
    	// ]]] end generated region [Generated Contents]
    	
    	}
    /** 
     * Destroy child controls.
     */
    CTestUIContainer::~CTestUIContainer()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	delete iLabel1;
    	iLabel1 = NULL;
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    /**
     * Construct the control (first phase).
     *  Creates an instance and initializes it.
     *  Instance is not left on cleanup stack.
     * @param aRect bounding rectangle
     * @param aParent owning parent, or NULL
     * @param aCommandObserver command observer
     * @return initialized instance of CTestUIContainer
     */
    CTestUIContainer* CTestUIContainer::NewL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CTestUIContainer* self = CTestUIContainer::NewLC( 
    			aRect, 
    			aParent, 
    			aCommandObserver );
    	CleanupStack::Pop( self );
    	return self;
    	}
    
    /**
     * Construct the control (first phase).
     *  Creates an instance and initializes it.
     *  Instance is left on cleanup stack.
     * @param aRect The rectangle for this window
     * @param aParent owning parent, or NULL
     * @param aCommandObserver command observer
     * @return new instance of CTestUIContainer
     */
    CTestUIContainer* CTestUIContainer::NewLC( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CTestUIContainer* self = new ( ELeave ) CTestUIContainer();
    	CleanupStack::PushL( self );
    	self->ConstructL( aRect, aParent, aCommandObserver );
    	return self;
    	}
    			
    /**
     * Construct the control (second phase).
     *  Creates a window to contain the controls and activates it.
     * @param aRect bounding rectangle
     * @param aCommandObserver command observer
     * @param aParent owning parent, or NULL
     */ 
    void CTestUIContainer::ConstructL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	if ( aParent == NULL )
    	    {
    		CreateWindowL();
    	    }
    	else
    	    {
    	    SetContainerWindowL( *aParent );
    	    }
    	iFocusControl = NULL;
    	iCommandObserver = aCommandObserver;
    	InitializeControlsL();
    	SetRect( aRect );
    	ActivateL();
    	// [[[ begin generated region: do not modify [Post-ActivateL initializations]
    	// ]]] end generated region [Post-ActivateL initializations]
    	
    	}
    			
    /**
    * Return the number of controls in the container (override)
    * @return count
    */
    TInt CTestUIContainer::CountComponentControls() const
    	{
    	return ( int ) ELastControl;
    	}
    				
    /**
    * Get the control with the given index (override)
    * @param aIndex Control index [0...n) (limited by #CountComponentControls)
    * @return Pointer to control
    */
    CCoeControl* CTestUIContainer::ComponentControl( TInt aIndex ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	switch ( aIndex )
    		{
    		case ELabel1:
    			return iLabel1;
    		}
    	// ]]] end generated region [Generated Contents]
    	
    	// handle any user controls here...
    	
    	return NULL;
    	}
    				
    /**
     *	Handle resizing of the container. This implementation will lay out
     *  full-sized controls like list boxes for any screen size, and will layout
     *  labels, editors, etc. to the size they were given in the UI designer.
     *  This code will need to be modified to adjust arbitrary controls to
     *  any screen size.
     */				
    void CTestUIContainer::SizeChanged()
    	{
    	CCoeControl::SizeChanged();
    	LayoutControls();
    	// [[[ begin generated region: do not modify [Generated Contents]
    			
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    // [[[ begin generated function: do not modify
    /**
     * Layout components as specified in the UI Designer
     */
    void CTestUIContainer::LayoutControls()
    	{
    	iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    	iLabel1->SetTextL(_L("Started..."));
    	}
    // ]]] end generated function
    
    void CTestUIContainer::setStatus(const TDesC& value){
    	iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    	iLabel1->SetTextL(value);
    	DrawNow();
    }
    /**
     *	Handle key events.
     */				
    TKeyResponse CTestUIContainer::OfferKeyEventL( 
    		const TKeyEvent& aKeyEvent, 
    		TEventCode aType )
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	
    	// ]]] end generated region [Generated Contents]
    	
    	if ( iFocusControl != NULL
    		&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
    		{
    		return EKeyWasConsumed;
    		}
    	return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
    	}
    				
    // [[[ begin generated function: do not modify
    /**
     *	Initialize each control upon creation.
     */				
    void CTestUIContainer::InitializeControlsL()
    	{
    	iLabel1 = new ( ELeave ) CEikLabel;
    	iLabel1->SetContainerWindowL( *this );
    		{
    		TResourceReader reader;
    		iEikonEnv->CreateResourceReaderLC( reader, R_TESTUICONTAINER_LABEL1 );
    		iLabel1->ConstructFromResourceL( reader );
    		CleanupStack::PopAndDestroy(); // reader internal state
    		}
    	
    	}
    // ]]] end generated function
    
    /** 
     * Handle global resource changes, such as scalable UI or skin events (override)
     */
    void CTestUIContainer::HandleResourceChange( TInt aType )
    	{
    	CCoeControl::HandleResourceChange( aType );
    	SetRect( iAvkonViewAppUi->View( TUid::Uid( ETestUIContainerViewId ) )->ClientRect() );
    	// [[[ begin generated region: do not modify [Generated Contents]
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    /**
     *	Draw container contents.
     */				
    void CTestUIContainer::Draw( const TRect& aRect ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	CWindowGc& gc = SystemGc();
    	gc.Clear( aRect );
    	
    	// ]]] end generated region [Generated Contents]
    	
    	}

    Frient this is not such a big deal and I think you are wrongly directed to problem...

    As I am seeing your code it is correct and you just need to call DrawNow function using your lable object.
    In your code:

    void CTestUIContainer::setStatus(const TDesC& value){
    iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    iLabel1->SetTextL(value);
    iLable1->DrawNow();
    }

    Just change Red colored portion in your code and enjoy the result...but make sure value should be const TDesC

    Have a good day...

  14. #14
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,078

    Re: SetTextL doesn't work!

    May be User::WaitForRequest(aStatus); is blocking the thread for any further operation which also includes the Drawing of the label.

  15. #15
    Registered User
    Join Date
    Oct 2010
    Posts
    37

    Re: SetTextL doesn't work!

    Quote Originally Posted by rohit.shah View Post
    Frient this is not such a big deal and I think you are wrongly directed to problem...

    As I am seeing your code it is correct and you just need to call DrawNow function using your lable object.
    In your code:

    void CTestUIContainer::setStatus(const TDesC& value){
    iLabel1->SetExtent( TPoint( 0, 2 ), TSize( 235, 119 ) );
    iLabel1->SetTextL(value);
    iLable1->DrawNow();
    }

    Just change Red colored portion in your code and enjoy the result...but make sure value should be const TDesC

    Have a good day...
    thanks for your reply, but please check out my last reply and I'll be so apprecited if you could possibly help me in this issue....

Similar Threads

  1. SetTextL problem
    By joteddy123 in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-03-24, 12:27
  2. How to use SetTextL() in CAknSettingItemList
    By saheb04 in forum Symbian
    Replies: 2
    Last Post: 2007-09-20, 06:24
  3. EEikEdwinUserSuppliedText and SetTextL
    By jbylund in forum Symbian User Interface
    Replies: 1
    Last Post: 2005-10-05, 03:23
  4. SetTextL() on target
    By yaront in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-01-24, 19:46
  5. SetTextL()
    By jesusdol in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-01-27, 18:44

Posting Permissions

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