Label and edit Learning

Source: Internet
Author: User
1. Label

A label is a label used to display on the screen. The usage is as follows:

  1. Create a traditional project
  2. Define a CEikLable class in the. h file of the container.
    Class CEikLable; defined by forward
  3. Add a class member variable CEikLable * iLabelTest;
  4. Add the include reference in the. cpp file of the container # include <eiklabel. h>
  5. Create the variable in the constructL method, as shown in the following code:
    ILabelTest = new (ELeave) CEikLabel; iLabelTest-> setcontainer1_wl (* this);/* set the font for the label by referencing eikenv. h. Therefore, you can obtain the CEikonEnv pointer through * CEikonEnv: Static (), and then call * its member method to obtain a const CFont pointer. ** other methods: Reference aknutils. h. You can get the system-defined font. * search for aknutils to find the global font. */const CFont * aFont = CEikonEnv: Static ()-> AnnotationFont (); iLabelTest-> SetFont (aFont); iLabelTest-> SetTextL (_ L ("label test"); iLabelTest-> SetUnderlining (ETrue);

    ILabelTest-> SetAlignment (EHRightVTop );

     

    The font is used here. You need to add the header file:
      # Include <eikenv. h> # include <gdi. h> # include <aknutils. h>

    # Include <gulalign. h>

    And corresponding library files
    Gdi. lib

  1. In SetExtent is required for CEikLable in the SizeChanged method.
    ILabelTest-> SetExtent (TPoint (50, 50), iLabelTest-> MinimumSize ());
    If you try to remove this label, the label cannot be displayed. This label is used to set the position and size of the display.
  2. CountComponentControls () and ComponentControl (TInt aIndex)
    Is used to return the total number of components in the container and the number
    Run the following code:
    // Counter // CsimplecontrolContainer: CountComponentControls () const // counter // TInt CsimplecontrolContainer: CountComponentControls () const {return 5; // return nbr of controls inside this container} // CsimplecontrolContainer: ComponentControl (TInt aIndex) const // component // CCoeControl * CsimplecontrolContainer: ComponentControl (TInt aIndex) const {switch (aIndex) {case 0: return iLabel; case 1: return iToDoLabel; case 2: return iLabelTest; case 3: return iDateEditor; case 4:// This is written as 5 during debugging, and the result is always incorrect because it takes a long time to locate the cause.Return iEdwin; default: return NULL ;}}

    //---------------------------------------------------------

     
  3. Compile and run the program to see the effect.
2. Edit the input control

When the exercise editing input control is used, CEikDateEditor is used.
The required header file is: # include <eikmfne. h>
The LIB library file is eikctl. lib.
RSS file definition:

RESOURCE DATE_EDITOR r_my_date_edit {minDate = DATE {year = 1900 ;}; maxDate = DATE {year = 2100 ;};

}

The difference between creating a CEikDateEditor and a lable is that lable is not put in rss, while CEikDateEdit is put in Rss,
The code for creating CEikDateEditor is as follows:

TResourceReader read; iCoeEnv-> convert (read, R_MY_DATE_EDIT); iDateEditor = new (ELeave) CEikDateEditor; iDateEditor-> setcontainer1_wl (* this); iDateEditor-> ConstructFromResourceL (read );

CleanupStack: PopAndDestroy ();

TResourceReader is used in the Code. This class must reference the header file: barsread. h and the library file: bafl. lib.

For general input controls CEikEdwin and CEikDateEditor, except for the rss definition, the definition and creation of other controls are the same.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.