Symbian学习笔记11 之 Querying Date and Time 

 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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值