×
Namespaces

Variants
Actions

Symbian C++ Common File Dialogs

From Nokia Developer Wiki
Jump to: navigation, search

This article demonstrates how to use the Symbian C++ Common File Dialogs. It includes both the resource file definitions for the different dialogs and code snippets showing how to use them.

Article Metadata
Article
Created: giridharn (30 May 2007)
Last edited: hamishwillee (02 Feb 2012)

Contents

.MMP

LIBRARY CommonDialogs.lib

.RSS

#include <CommonDialogs.hrh> // Enumerations
#include <CommonDialogs.rh> // Resource structures


MEMORYSELECTIONDIALOG resource

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.

FILESELECTIONDIALOG resource

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
}
};
}

FILENAMEPROMPTDIALOG resource

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\\"; }
};
}
This page was last modified on 2 February 2012, at 04:56.
44 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.

×