Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Oct 2007

    code for gui application with a labels and a textboxes

    hello Sir,

    i want a sample code to add labels and textboxes on display

    thanking you.

  2. #2
    Registered User
    Join Date
    Dec 2006

    Re: code for gui application with a labels and a textboxes

    Here is the code of Container class constructl method.it will display 2 labels and 2 text fields. u can adjust its x,y positions in sizechanged method

    In .h class

    CEikLabel* iLabel1;
    CEikLabel* iLabel2;
    CEikEdwin* iTextField1;
    CEikEdwin* iTextField2;

    IN .cpp class

    void CRegistrationContainer::ConstructL(const TRect& aRect)
    iLabel1 = new (ELeave) CEikLabel;
    iLabel1 ->SetContainerWindowL( *this );
    iLabel1 ->SetTextL( _L("Label1") );
    iLabel1 ->OverrideColorL( EColorLabelTextEmphasis, KRgbGreen );
    iLabel1 ->SetEmphasis( CEikLabel::EPartialEmphasis );
    iLabel1 ->DrawDeferred();
    iLabel1 ->SetBrushStyle( CWindowGc::ENullBrush );

    iLabel2= new (ELeave) CEikLabel;
    iLabel2->SetContainerWindowL( *this );
    iLabel2->SetTextL( _L("Label2") );
    iLabel2->OverrideColorL( EColorLabelTextEmphasis, KRgbBlack );
    iLabel2->SetEmphasis( CEikLabel::EPartialEmphasis );
    iLabel2->SetBrushStyle( CWindowGc::ENullBrush );

    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC( reader, R_TEXT_BOX);
    iTextField1 = new ( ELeave ) CEikEdwin();
    iTextField1 ->SetContainerWindowL( *this );
    iTextField1 ->ConstructFromResourceL( reader );
    CleanupStack::PopAndDestroy(); // Resource reader
    iTextField1 ->SetAknEditorInputMode( EAknEditorTextInputMode );

    iCoeEnv->CreateResourceReaderLC( reader, R_TEXT_BOX );
    iTextField2 = new ( ELeave ) CEikEdwin();
    iTextField2 ->SetContainerWindowL( *this );
    iTextField2 ->ConstructFromResourceL( reader );
    CleanupStack::PopAndDestroy(); // Resource reader
    iTextField2 ->SetAknEditorInputMode( EAknEditorTextInputMode );

    iTextField1 ->SetMaxLength(25);
    iTextField2 ->SetMaxLength(25);
    iTextField1 ->SetTextL(&_L("1st Text Filed"));
    iTextField2 ->SetTextL(&_L("2nd Text Filed"));

    iTextField1 ->SetFocus( ETrue );
    iTextField2 ->SetBorder(ENone);
    iTextField1 ->SetBorder(ENone);
    iTextField2 ->MakeVisible(ETrue);


    In .rss class

    RESOURCE EDWIN r_text_box
    flags = EAknEditorFlagDefault ;//| EEikEdwinResizable;
    width = 2;
    lines = 1;
    maxlength= 1;

    and distroy objects in destructor and also write its offerkeyeventL method 2 handle textbox events.

    Asfi Nazir

Similar Threads

  1. 6600 VM woes, or "why is my program crashing randomly?"
    By bubbasbits in forum Mobile Java General
    Replies: 0
    Last Post: 2004-11-25, 04:47

Posting Permissions

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