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

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").

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值