×

Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    25

    Using CEikTelephoneNumberEditor to query telephone numbers

    How can I easily query the user for a telephone number?

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    157

    RE: Using CEikTelephoneNumberEditor to query telephone numbers

    CEikTelephoneNumberEditor is a ready editor for typing in a telepnone numbe in three sections: country code, area code and recipients number.

    Here is a coding example of the use of CEikTelephoneNumberEditor
    .

    First you define your own Telephone Number Dialog in the resource(.rss) file:

    #include "myapp.hrh"

    RESOURCE DIALOG r_myapp_tel_number_dialog
    {
    title = "Telephone Number";
    buttons = R_EIK_BUTTONS_CANCEL_OK;
    flags = EEikDialogFlagWait;
    items =
    {
    DLG_LINE
    {
    type = EEikCtTelephoneNumberEditor;
    prompt = "Recipient";
    id = EMYAPPTelNumEditor;
    control = TELNUMBER
    {
    country_prompt = "[country]";
    area_prompt = "[area]";
    number_prompt = "[number]";
    widthinpixels = 200;
    };
    }
    };
    }



    In the .hrh file we define an enumeration id for this dialog:

    enum
    {
    EMYAPPTelNumEditor //this defaults to 0
    };


    In the header file you must include eikdialg.h and declare the dialog.


    #include <eikdialg.h>

    const TInt KMaxTelephoneNumberLength = 30; // define max length for number

    class CMYAPPTelNumDialog : public CEikDialog
    {
    public:
    CMYAPPTelNumDialog(TDesC& aRecipientsTelNum);
    private:
    TBool OkToExitL(TInt aButtonId);
    void PreLayoutDynInitL();
    private:
    TDesC* iRecipientsTelNum; //the telNumber is stored here
    };


    And finally in the .cpp file we define the controls for showing the dialog:




    CMYAPPTelNumDialog::CMYAPPTelNumDialog(TDesC& aRecipientsTelNum)
    : iRecipientsTelNum(&aRecipientsTelNum)
    {
    }


    void CMYAPPTelNumDialog::PreLayoutDynInitL()
    { (static_cast<CEikTelephoneNumberEditor*>(Control(EMYAPPTelNumEditor)))->SetNumberL(*iRecipientsTelNum);
    }


    TBool CMYAPPTelNumDialog::OkToExitL(TInt /*aButtonId*/)
    {
    TBuf<KMaxTelephoneNumberLength> recipientsTelNum;
    (static_cast<CEikTelephoneNumberEditor*>(Control(EMYAPPTelNumEditor)))->GetNumber(recipientsTelNum);
    if (recipientsTelNum.Length()==0)
    {
    iEikonEnv->InfoMsg(R_MYAPP_TEL_NUMBER_DIALOG);
    return EFalse;
    }
    (static_cast<HBufC*>(iRecipientsTelNum))->Des()=recipientsTelNum;
    return ETrue;
    }


    This is how you set and use the dialog:

    iRecipient=HBufC::NewL(KMaxTelephoneNumberLength);

    CMYAPPTelNumDialog* telNumDialog = new(ELeave) CMYAPPTelNumDialog(*iRecipient);

    telNumDialog->ExecuteLD(R_MYAPP_TEL_NUMBER_DIALOG);

    // now iRecipient has the telephone number

Posting Permissions

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