Querying Strings
Article Metadata
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 );
}
};


(no comments yet)