Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Querying Strings

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: symbianyucca (09 Apr 2007)
Last edited: hamishwillee (26 Jul 2012)
Reviewer Approved    Thumbs up icon sm.jpg

The CAknTextQueryDialog API is designed for querying text strings from the user. The following function shows how to use it:

TInt ShowQueryDialogL(const TDesC& aTitle, TDes& aBuffer)
{
CAknTextQueryDialog* Dialog =
CAknTextQueryDialog::NewL(aBuffer,CAknQueryDialog::ENoTone);
Dialog->PrepareLC(R_ASK_NAME_DIALOG);
Dialog->SetPromptL(aTitle);
return Dialog->RunLD();
}

Like all dialogs the CAknTextQueryDialog also requires resource definition. This example uses the following resource definition:

RESOURCE DIALOG R_ASK_NAME_DIALOG
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items=
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control= AVKON_DATA_QUERY
{
layout = EDataLayout;
control = EDWIN
{
flags= EEikEdwinNoHorizScrolling | EEikEdwinResizable;
maxlength = 250;
width = 4;
lines = 1;
};
};
}
};
}


It is also possible to subclass CAknTextQueryDialog in order to override some of its inherit behavior. For example, to override what is acceptable input and therefore show/hide the left softkey option:

class CMyTextQueryDialog : public CAknTextQueryDialog
{
public:
CMyTextQueryDialog (TDes &aDataText, const TTone &aTone=ENoTone) :
CAknTextQueryDialog(aDataText, aTone) {}
 
virtual void UpdateLeftSoftKeyL ()
{
// 0 or more characters allowed
MakeLeftSoftkeyVisible( ETrue );
}
};
This page was last modified on 26 July 2012, at 05:02.
31 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×