Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22218
  • 博文数量: 28
  • 博客积分: 670
  • 博客等级: 上士
  • 技术积分: 285
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-09 11:27
文章分类

全部博文(28)

文章存档

2011年(28)

我的朋友
最近访客

分类: 嵌入式

2011-01-29 12:29:27

The CAknTimeQueryDialog API is designed for querying time and date values from the user. The following function shows how you can use it:

TInt ShowQueryDialogL(const TDesC& aTitle, TTime& aTime)
{
CAknTimeQueryDialog* Dialog =
CAknTimeQueryDialog::NewL(aTime,CAknQueryDialog::ENoTone);
Dialog->PrepareLC(R_TIME_QUERY);
Dialog->SetPromptL(aTitle);
return Dialog->RunLD();
}

Like all dialogs the CAknTimeQueryDialog also requires resource definition. In this example function you could use one of the following resource definition. The R_DATE_QUERY can be used to query date values and R_TIME_QUERY can be used to query time values.

RESOURCE DIALOG r_date_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_DATA_QUERY
{
layout = EDateLayout;
label = "";
control = DATE_EDITOR
{
minDate = DATE
{
year = 1973;
month = 2;
day = 17;
};
maxDate = DATE
{
year = 2973;
month = 2;
day = 17;
};
flags = 0;
};
};
}
};
}
 
RESOURCE DIALOG r_time_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_DATA_QUERY
{
layout = ETimeLayout;
label = "Alarm Time";
control = TIME_EDITOR
{
minTime = TIME
{
second = 0;
minute = 0;
hour = 0;
};
maxTime = TIME
{
second = 59;
minute = 59;
hour = 23;
};
flags = EEikTimeWithoutSecondsField;
};
};
}
};
}

To query both date and time same time, you could utilize CAknMultiLineDataQueryDialog API. The following sample code shows how it is used:

TInt ShowQueryDialogL(TTime& aDate,TTime& aTime)
{
CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(aDate,aTime);
return dlg->ExecuteLD(R_DATE_TIME_QUERY);
}

The resource definitions for this sample code:

RESOURCE DIALOG r_date_time_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineFirstLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataFirstDateEd;
label = "Date";
control = DATE_EDITOR
{
minDate = DATE
{
year = 2006;
};
maxDate = DATE
{
year = 2599;
};
flags = 0;
};
};
},
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineSecondLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataSecondTimeEd;
label = "Time";
control = TIME_EDITOR
{
minTime = TIME
{
second = 0;
minute = 0;
hour = 0;
};
maxTime = TIME
{
second = 59;
minute = 59;
hour = 23;
};
flags = EEikTimeWithoutSecondsField |
EEikTimeForce24HourFormat;
};
};
}
};
}

常用数据查询对话框

 

类型

布局

控件

无格式文本

CAknTextQueryDialog

EDataLayout

EDWIN

电话号码

CAknTextQueryDialog

EPhoneLayout

EDWIN

PIN

CAknTextQueryDialog

EPinLayout

SECRETED

口令

CAknTextQueryDialog

ECodeLayout

SECRETED

日期

CAknTextQueryDialog

EDateLayout

DATE_EDITOR

时间

CAknTextQueryDialog

ETimeLayout

TIME_EDITOR

持续期

CAknDurationQueryDialog

EDurationLayout

TIME_EDITOR

浮点数

CAknFloatingPointQueryDialog

EFloatintPointLayout

FLPTED

多行

CAknMultiLineDataQueryDialog

EAknMultiLineDataQueryLayout

根据使用而不同

数字

CAknNumberQueryDialog

ENumberLayout

AVKON_INTEGR_EDWIN


阅读(296) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~