Symbian 控件架构之对话框
2010-04-20 15:44:00 来源:WEB开发网CAknQueryDialog
头文件:AknQueryDialog.h
lib:avkon.lib
使用方法:
Code:
CAknQueryDialog* dlg;
dlg = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
dlg->PrepareLC( R_RESOURCE_QUERY_DIALOG ); //从资源文件构造对话框,资源见下面的定义
TInt ret = dlg->RunLD(); //若用户选择“是”,返回非0,选择“否”,则返回0
RESOURCE DIALOG R_RESOURCE_QUERY_DIALOG //询问对话框资源
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_YES_NO; //CBA显示“是”和“否”两个按钮
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_CONFIRMATION_QUERY //表示这是confirm询问对话框,用户选择“是”或“否”
{
layout = EConfirmationQueryLayout;
label = "对话框中显示的文字";
};
}
};
}
此类对话框可以有声音提示,由NewL的const TTone& aTone参数指定,可能的值如下:
Code:
enum TTone {
/// No tone is played
ENoTone = 0,
/// A confirmation tone is played
EConfirmationTone = EAvkonSIDConfirmationTone,
/// A warning tone is played
EWarningTone = EAvkonSIDWarningTone,
/// An error tone is played
EErrorTone = EAvkonSIDErrorTone
};
通过定义不同的询问对话框资源,可实现不同的询问对话框,如让用户输入文字的询问对话框资源定义如下:
Code:
RESOURCE DIALOG R_RESOURCE_DATA_QUERY
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL; //CBA按钮显示“确定”和“取消”
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_DATA_QUERY //表示这是data询问对话框,需要用户输入内容
更多精彩
赞助商链接