×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    41

    Cannot write in text box

    Hey, I'm using View in my program. The view contains a Label and an Edwin control. But i'm not being able to write in the text box. Here's my code below


    // the header file
    #ifndef __GUIAPP_CONTAINER1_H__
    #define __GUIAPP_CONTAINER1_H__

    #include <aknview.h>

    #define EDWIN_LABEL_POS TPoint( 5, 10 )
    #define EDWIN_POS TPoint( 10, 25 )

    const TInt KNumberOfControls = 2;
    const TInt KBufLength = 64;

    enum TControls
    {
    EEdwinPrompt,
    EEdwin
    };

    class CEikLabel;
    class CEikEdwin;

    class CGUIAppContainer1 : public CCoeControl, MCoeControlObserver
    {
    public:
    static CGUIAppContainer1* NewL( const TRect& aRect );
    static CGUIAppContainer1* NewLC( const TRect& aRect );
    void ConstructL( const TRect& aRect );
    ~CGUIAppContainer1();
    public:
    TInt CountComponentControls() const;
    CCoeControl* ComponentControl( TInt aIndex ) const;
    void Draw( const TRect& aRect ) const;
    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
    TEventCode aType );
    private:
    void HandleControlEventL( CCoeControl* /*aControl*/,
    TCoeEvent /*aEventType*/ );
    private:
    CEikLabel* iLabel;
    CEikEdwin* iEdwin;
    };

    #endif

    // the cpp file

    #include <eiklabel.h>
    #include <eikedwin.h>
    #include <barsread.h>

    #include <GUIApp.rsg>
    #include "GUIApp.hrh"
    #include "GUIAppContainer1.h"

    CGUIAppContainer1* CGUIAppContainer1::NewL( const TRect& aRect )
    {
    CGUIAppContainer1* self = CGUIAppContainer1::NewLC( aRect );
    CleanupStack::Pop( self );
    return self;
    }

    CGUIAppContainer1* CGUIAppContainer1::NewLC( const TRect& aRect )
    {
    CGUIAppContainer1* self = new ( ELeave ) CGUIAppContainer1;
    CleanupStack::PushL( self );
    self->ConstructL( aRect );
    return self;
    }

    void CGUIAppContainer1::ConstructL( const TRect& aRect )
    {
    CreateWindowL();
    TBuf<KBufLength> text;

    iCoeEnv->ReadResource( text, R_GUIAPP_VIEW1_LABEL );
    iLabel = new ( ELeave ) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( text );
    iLabel->SetExtent( EDWIN_LABEL_POS, iLabel->MinimumSize() );


    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC( reader, R_GUIAPP_VIEW1_EDWIN );
    iEdwin = new ( ELeave ) CEikEdwin;
    iEdwin->SetContainerWindowL( *this );
    iEdwin->ConstructFromResourceL( reader );
    CleanupStack::PopAndDestroy(); // Resource reader
    iEdwin->SetExtent( EDWIN_POS, iEdwin->MinimumSize() );

    iEdwin->SetFocus( ETrue );

    SetRect( aRect );
    ActivateL();
    }

    TInt CGUIAppContainer1::CountComponentControls() const
    {
    return KNumberOfControls;
    }

    CCoeControl* CGUIAppContainer1::ComponentControl( TInt aIndex ) const
    {
    switch( aIndex )
    {
    case EEdwinPrompt:
    return iLabel;
    case EEdwin:
    return iEdwin;
    default:
    return NULL;
    }
    }

    void CGUIAppContainer1::Draw( const TRect& aRect ) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

    TKeyResponse CGUIAppContainer1::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType )
    {
    //if( iEdwin )
    {
    //if( iEdwin->IsFocused() )
    {
    return iEdwin->OfferKeyEventL( aKeyEvent, aType );
    }
    }
    }

    void CGUIAppContainer1::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/ )
    {
    }

    CGUIAppContainer1::~CGUIAppContainer1()
    {
    delete iLabel;
    delete iEdwin;
    }

    Can anybody suggest me what the problem might be ?

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,692

    Re: Cannot write in text box

    Have you put your control on the Control Stack (AppUi::AddToStackL)?

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    41

    Re: Cannot write in text box

    Thank you a lot man, it worked gr8. You're simply awesome. Thanks

Similar Threads

  1. write body text to file
    By aden2004 in forum Symbian
    Replies: 3
    Last Post: 2007-03-26, 22:01
  2. Custom text box..
    By vishwas_vincy11 in forum Symbian User Interface
    Replies: 2
    Last Post: 2006-09-13, 11:40
  3. write text into file *.pho for MBROLA
    By jend_rommel in forum Symbian
    Replies: 1
    Last Post: 2005-11-14, 10:47
  4. Text distortion on series 60 dialog box
    By ronoc in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2005-02-04, 16:09
  5. how edit a text box
    By CristianMoron in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-05-20, 22:14

Posting Permissions

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