Use of various prompts and input dialog boxes for "share"

Source: Internet
Author: User
1. Non-blocking prompt box
Symbian defines several prompt classes:
Confirm class: caknconfirmationnote
Info class: cakninformationnote
Warning class: caknwarningnote
Error class: caknerrornote
Header file: aknnotewrappers. h
Lib: avkon. Lib eikcdlg. Lib eikctl. Lib

Usage: code:

TBuf<32> buf;buf.Copy(_L("info note"));CAknInformationNote* iInfoNote = new (ELeave) CAknInformationNote;iInfoNote->ExecuteLD(buf);

The prompt box does not block the thread. After executeld executes the prompt box, the subsequent statements continue to be executed.

2. Blocking prompt box
Void ceikonenv: alertwin (const tdesc & amsg );
Void ceikonenv: alertwin (const tdesc & amsg1, const tdesc & amsg2 );
Static void ceikonenv: infowinl (const tdesc & afirstline, const tdesc & asecondline );

Alertwin is a non-static member function of the ceikonenv class, And infowinl is a static member function of the ceikonenv class.
Alertwin can only be used in the UI, view, and container. The usage is as follows: code:

iEikonEnv->AlertWin(_L("text"));

Infowinl can be used in any class as follows: code:

CEikonEnv::Static()->InfoWinL(_L("note:"), _L("text"));

For ease of use, macro is often defined to use such prompt boxes, such as: code:

# Define debug_dialog (x) ieikonenv-> alertwin (# X); # define debug_dialog1 (x) ceikonenv: static ()-> infowinl (_ L ("Note: "), # X); # define debug_dialog2 (x, y) ceikonenv: static ()-> infowinl (# X, # Y); you can use this: tbuf <32> Buf; Buf. copy (_ L ("test"); debug_dialog (BUF); debug_dialog1 (BUF); debug_dialog2 (BUF, _ L ("text "));

This type of prompt box can block the thread in s60 2nd. Only after the user presses the button to exit the prompt box can the subsequent program run. In s60 3rd, the thread is not blocked.

3. Progress bar dialog box
The progress bar dialog box is as follows:
Caknprogressdialog
Header file: aknprogressdialog. h
Lib: avkon. Lib eikcdlg. Lib eikctl. Lib

Usage:

Code:
// Initialization progress bar caknprogressdialog * progress; ceikprogressinfo * iprogressinfo; Progress = new (eleave) caknprogressdialog (reinterpret_cast <ceikdialog **> (& progress); Progress-> setcallback (this ); iprogressdialog-> preparelc (export); // The create from resource file dialog box. for resources, see the definition iprogressinfo = iprogressdialog-> getprogressinfol (); iprogressinfo-> setfinalvalue (amaxvalue ); // set the maximum value (end value) of the progress bar iprogressdialog-> runld (); // update the progress bar iprogressinfo-> incrementanddraw (astep); // The progress bar iprogressdialog-> processfinishedl (); delete iprogressdialog; resource dialog r_resource_progress_note // Resources in the progress bar dialog box {flags = eaknprogressnoteflags; buttons = success; items = {dlg_line {type = eaknctnote; id = success; control = avkon_note {layout = eprogresslayout; singular_label = "text displayed in the dialog box"; plural_label = "Download"; imagefile = avkon_bmp file_name; // In version 2, the icon file is # define avkon_bmp file_name "Z: // system // data // avkon. MBM "imageid = embmavkonqgn_note_sml; // The two icons can be changed to display different imagemask = embmavkonqgn_note_sml_mask ;};}};}

4. waiting dialog box
Classes to be used in the wait dialog box:
Caknglobalnote
Header file: aknglobalnote. h
Lib: aknnotify. Lib eiksrv. Lib

Usage: code:

// Display the waiting dialog box caknglobalnote * globalnote = caknglobalnote: newl (); cleanupstack: pushl (globalnote); tint iwaitnoteid = globalnote-> shownotel (eaknglobalwaitnote, _ l ("text displayed in the dialog box"); cleanupstack: popanddestroy (); // caknglobalnote * Note = caknglobalnote: newl (); cleanupstack :: pushl (Note); note-> cancelnotel (iwaitnoteid); cleanupstack: popanddestroy ();

Note:
In addition to the waiting dialog box, the caknglobalnote class can also display multiple types of global dialogs. The specific types can be specified by the first parameter of shownotel. The possible types are as follows:

Code:
enum TAknGlobalNoteType{EAknGlobalInformationNote = 1,EAknGlobalWarningNote,EAknGlobalConfirmationNote,EAknGlobalErrorNote,EAknGlobalChargingNote,EAknGlobalWaitNote,EAknGlobalPermanentNote,EAknGlobalNotChargingNote,EAknGlobalBatteryFullNote,EAknGlobalBatteryLowNote,EAknGlobalRechargeBatteryNote,EAknCancelGlobalNote,EAknGlobalTextNote};

5. Dialog Box
Classes used in the query dialog box:
Caknquerydialog
Header file: aknquerydialog. h
Lib: avkon. Lib

Usage: code:

Caknquerydialog * DLG; DLG = caknquerydialog: newl (caknquerydialog: enotone); DLG-> preparelc (r_resource_query_dialog); // create a dialog box from the resource file, for resources, see the following definition tint ret = DLG-> runld (); // if the user selects "yes", return non-0, and select "no ", returns 0 resource dialog r_resource_query_dialog // The resource in the query dialog box {flags = egeneralqueryflags; buttons = r_avkon_softkeys_yes_no; // The buttons "yes" and "no" are displayed in the CBA. Items = {dlg_line {type = eaknctquery; id = egeneralquery; control = avkon_confirmation_query // indicates the confirm query dialog box, select "yes" or "no" {layout = econfirmationquerylayout; label = "text displayed in the dialog box ";};}};}

This type of dialog box can have a sound prompt, which is specified by newl's const ttone & atone parameter. The possible values are as follows: code:

enum TTone {    /// No tone is played     ENoTone = 0,            /// A confirmation tone is played     EConfirmationTone = EAvkonSIDConfirmationTone,     /// A warning tone is played     EWarningTone = EAvkonSIDWarningTone,          /// An error tone is played      EErrorTone = EAvkonSIDErrorTone             };

You can define different dialog box resources to implement different dialog boxes. For example, the resource definition of the dialog box that allows users to enter text is as follows: code:

Resource dialog r_resource_data_query {flags = egeneralqueryflags; buttons = Batch; // The CBA button displays "OK" and "cancel" items = {dlg_line {type = eaknctquery; id = egeneralquery; control = avkon_data_query // indicates that this is the data query dialog box. You must enter {layout = edatalayout; label = "prompt content"; control = Edwin {flags = eeikedwinnohorizscrolling | eeikedwinresizable; width = 30; lines = 2; maxlength = 159 ;};};}};}

Usage: code:

TBuf<128> msg;CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(msg,CAknQueryDialog::ENoTone);  TInt ret = dlg->ExecuteLD(R_RESOURCE_DATA_QUERY);

After the user inputs the content, press "OK", and the content is stored in MSG. The function returns non-0. Press "cancel" and the function returns 0.

The class used here is caknquerydialog, a subclass of cakntextquerydialog.
The subclasses of caknquerydialog include: code:

CAknFloatingPointQueryDialog  //This class should be used when user is reguest to enter a flotaing point number  CAknFixedPointQueryDialog     //...  CAknDurationQueryDialog       //This class should be used when user is reguest to enter duration  CAknIpAddressQueryDialog      //This class should be used when user is reguest to enter IP address,@since 2.1  CAknMultiLineDataQueryDialog  //Query Dialog with data input on more than one line (2 lines at the moment)Create using NewL methods and passing parameters as appropriate.Attention: When deriving from this class, you must call SetDataL during second phase construction.  CAknMultiLineIpQueryDialog    //...  CAknNumberQueryDialog         //This class should be used when user is reguest to enter number  CAknTextQueryDialog           //This class should be used when user is reguest to enter plain text, secret text, phonenumber or PIN-codeCAknTimeQueryDialog           //This class should be used when user is reguest to enter time or date

Resource files are different when different classes are used.

In addition, when defining Edwin in a resource, you can specify the input and output, such as: code:

Control = Edwin {flags = eeikedwinnohorizscrolling | eeikedwinresizable; width = 11; lines = 1; maxlength = 11; avkon_flags = eakneditorflagfixedcase | eakneditorflagnot9 | release; // disable the switching Input key allowed_input_modes = eakneditornumericinputmode; default_input_mode = eakneditornumericinputmode; numeric_keymap = eakneditorplainnumbermodekeymap ;};

The above statement indicates that the default input method is a number, and the switch key of the input method is disabled. That is, the switch key of the input method cannot be used to switch the input method.

6. edit box
Class used in the edit box:
Ceikglobaltexteditor
Header file: eikgted. h

Usage: code:

Ceikglobaltexteditor * igkeyed; tbuf <128> ikeytext; tresourcereader reader; icoeenv-> createresourcereaderlc (reader, r_resource_editor); // constructs an editing box from the resource file, for resources, see the following definition: igkeyed = new (eleave) ceikglobaltexteditor; igkeyed-> setcontainer1_wl (* This); igkeyed-> constructfromresourcel (Reader); cleanupstack: popanddestroy (); // resource reader // sets the initial text and position of the editing box. The size of the editing box defines tbuf <32> Buf; Buf in the resource. copy (_ L ("Demo"); igkeyed-> settextl (& BUF); igkeyed-> setextent (tpoint (5, 2), igkeyed-> minimumsize ()); igkeyed-> setfocus (etrue); // igkeyed-> setreadonly (etrue); // The edit box is read-only. // The text is centered in cparaformat paraformat; tparaformatmask paraformatmask; paraformatmask. setattrib (eattalignment); // set mask paraformat. ihorizontalalignment = cparaformat: ecenteralign; igkeyed-> applyparaformatl (& paraformat, paraformatmask); igkeyed-> gettext (ikeytext); // get the content in the edit box, save to ikeytext resource gtxted r_resource_editor // edit box resource {flags = eakneditorflagdefault; width = 53; Height = 16; numlines = 1; textlimit = 1; fontcontrolflags = egulfontcontrolall; fontnameflags = egulnosymbolfonts; // The input method can also be set here // avkon_flags = bytes | percent; // The eakneditorflagsupressshiftmenu /allowed_input_modes = percent; // default_input_mode = percent; // numeric_keymap = eakneditorplainnumbermodekeymap ;}

Note: To display the edit box properly, remember to change the countcomponentcontrols and componentcontrol functions of the container to correctly process the number of controls and the edit box pointer. In addition, to enable the edit box to normally receive button events, you must call the edit box's offerkeyeventl function, as shown in the following code:

TKeyResponse CMobileGuardSetKeyContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ){    return iGKeyEd->OfferKeyEventL( aKeyEvent, aType );}

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.