您的位置:首页 > 其它

vc 中添加 时间控件,尤其是小时分钟控件

2010-06-04 09:49 555 查看
Project -》Add to Project

插入 Microsoft Date and Time Picker Control 控件

然后 Controls里面就会多出一个控件来,

拉一个到对话框中, 其ID为 IDC_DATETIMEPICKER1

然后设置其格式。。。

下面是参考的

http://topic.csdn.net/u/20080315/12/AE6C4745-AF7B-4BBD-AA9F-D6F299DA2367.html

=========================

没有必要去insert 额外的控件,

vC自带的标准控件 date time picker 就足够了。

Example

void CDatesDlg::OnButton2()
{
// Gain a pointer to the control
CDateTimeCtrl* pCtrl = (CDateTimeCtrl*) GetDlgItem(IDC_DATETIMEPICKER1);
ASSERT(pCtrl != NULL);

// The control will create itself with a format that matches the
// locale setting in Control Panel. But we can force a particular
// format with a call to SetFormat(). This call forces the format
// dd-MMM-yy, which would show 03-APR-98 for April 3rd, 1998.

pCtrl->SetFormat(_T("dd-MMM-yy hh:mm"));
}

Element Description
"d" The one- or two-digit day.
"dd" The two-digit day. Single-digit day values are preceded by a zero.
"ddd" The three-character weekday abbreviation.
"dddd" The full weekday name.
"h" The one- or two-digit hour in 12-hour format.
"hh" The two-digit hour in 12-hour format. Single-digit values are preceded by a zero.
"H" The one- or two-digit hour in 24-hour format.
"HH" The two-digit hour in 24-hour format. Single-digit values are preceded by a zero.
"m" The one- or two-digit minute.
"mm" The two-digit minute. Single-digit values are preceded by a zero.
"M" The one- or two-digit month number.
"MM" The two-digit month number. Single-digit values are preceded by a zero.
"MMM" The three-character month abbreviation.
"MMMM" The full month name.
"t" The one-letter AM/PM abbreviation (that is, AM is displayed as "A").
"tt" The two-letter AM/PM abbreviation (that is, AM is displayed as "AM").
"yy" The last two digits of the year (that is, 1996 would be displayed as "96").
"yyyy" The full year (that is, 1996 would be displayed as "1996").
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: