Contents |
LIBRARY CommonDialogs.lib
#include <CommonDialogs.hrh> // Enumerations
#include <CommonDialogs.rh> // Resource structures
It defines a root path and a default folder. "root_path" is the absolute path to be considered as root when browsing, e.g. "C:\Nokia\". "default_folder" is the folder where browsing is started, e.g. "Images\Pictures\". LOCATION structures must be defined for phone memory and memory card. An example memory selection resource could look like this:
RESOURCE MEMORYSELECTIONDIALOG r_memory_selection_dialog
{
title = "Choose memory:";
softkey_1 = "Accept";
softkey_2 = "Negative";
locations =
{
LOCATION { root_path = "C:\\Nokia\\"; },
LOCATION { root_path = "E:\\"; default_folder ="Images\\";}
};
}
In this example, root path for phone memory is “C:\Nokia\” (remember the trailing backslash) and browsing is started from that directory if phone memory is selected. Root path for memory card is “E:\” and the browsing is started from the default folder, “E:\Images\”. You can leave any of the resource items undefined. In that case, default values are used.
RESOURCE FILESELECTIONDIALOG r_file_selection_dialog
{
title = "Select-a-file:";
root_path = "C:\\Nokia\\Images\\";
filters =
{
FILTER
{
filter_type = EAttributeFilter;
filter_style = EExclusiveFilter;
filter_data = { "SH", "R" }; // Excludes system, hidden and read-only attributes
}
};
}
RESOURCE FILENAMEPROMPTDIALOG r_filename_prompt_dialog
{
filename_prompt = "Enter filename:";
default_filename = "Attachment.jpg";
path = “C:\\Nokia\\Images\\”;
}
All UI components (CAknFileNamePromptDialog, CAknFileSelectionDialog, CAknMemorySelection and CAknMemorySelectionSettingPage) can be created with NewL and launched with ExecuteL. There are also easier ways to launch dialogs: single function calls (RunDlgLD). Include headers of Common Dialogs that you need in your .CPP file:
#include <AknCommonDialogs.h> // For single function calls
#include <CAknMemorySelectionDialog.h>
#include <CAknMemorySelectionSettingPage.h>
#include <CAknFileSelectionDialog.h>
#include <CAknFileNamePromptDialog.h>
//Example of launching a dialog:
_LIT(KDefaultFileName, "Attachment.jpg");
TFileName defaultFileName(KDefaultFileName);
AknCommonDialogs::RunSaveDlgLD(defaultFileName, R_MEMORY_SELECTION_DIALOG);
The resource:
RESOURCE MEMORYSELECTIONDIALOG r_memory_selection_dialog
{
locations =
{
LOCATION { root_path = "C:\\Nokia\\Images\\"; },
LOCATION { root_path = "E:\\"; default_folder = "Images\\"; }
};
}
No related wiki articles found