The CAknListQueryDialog API is designed for asking user to select options presented as a list. The following function shows how to use it:
TInt ShowQueryDialogL(CArrayPtr< CGulIcon >* aIcons,
CDesCArray* aSelectArrray, CArrayFixFlat<TInt>* aSelectedItems)
{
CAknListQueryDialog* dialog =
new(ELeave)CAknListQueryDialog(aSelectedItems);
dialog->PrepareLC(R_SELECTION_QUERY);
dialog->SetItemTextArray(aSelectArrray);
dialog->SetOwnershipType(ELbmDoesNotOwnItemArray);
dialog->SetIconArrayL(aIcons);
return dialog->RunLD();
}
The aIcons argument variable should be an icon array that includes two icons with masks. The first is for selected items and the second is for unselected items. The aSelectArray should have the text item array used with the listbox. The text strings also need to include the icon index and with two icons the index for text string icons should be 1. The aSelectedItems argument variable will hold indices of the selected items when finished.
Like all dialogs the CAknListQueryDialog also requires resource definition. This example function uses the following resource definition:
RESOURCE DIALOG r_selection_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtListQueryControl;
id = EListQueryControl;
control = AVKON_LIST_QUERY_CONTROL
{
listtype = EAknCtSingleGraphicPopupMenuListBox;
listbox = LISTBOX
{
flags = EAknListBoxMultiselectionList;
height = 3;
width = 3;
};
heading = "Select";
};
}
};
}
No related wiki articles found