但我却不知道如何清空 CDateTimeCtrl !
3 个解决方案
#1
呵呵, 这个问题的确不好解决啊! 我想到一个办法:
Derive a class from CDateTimeCtrl, and over write its message function OnPaint(). In the OnPaint() function, you should do something funny:
(1) Define a BOOL variable that indicates whether the date is empty in your control;
(2) If you want it to be empty, change the BOOL variable, and cancel the executation of CDateTimeCtrl::OnPaint(), replacing it simply by the following code:
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
(3) If you want to keep the date significant in the control, please execute the only code:
CDateTimeCtrl::OnPaint();
You will see the following codes:
BOOL m_bEmptyDateTime;
if(m_bEmptyDateTime)
{
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
}
else
CDateTimeCtrl::OnPaint();
Derive a class from CDateTimeCtrl, and over write its message function OnPaint(). In the OnPaint() function, you should do something funny:
(1) Define a BOOL variable that indicates whether the date is empty in your control;
(2) If you want it to be empty, change the BOOL variable, and cancel the executation of CDateTimeCtrl::OnPaint(), replacing it simply by the following code:
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
(3) If you want to keep the date significant in the control, please execute the only code:
CDateTimeCtrl::OnPaint();
You will see the following codes:
BOOL m_bEmptyDateTime;
if(m_bEmptyDateTime)
{
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
}
else
CDateTimeCtrl::OnPaint();
#2
我试试看
#3
呵呵,这其实也是一个好方法,但这样子只是把时间隐藏了而已,但控件里面还是有时间
还有其它更好的方法不/
#1
呵呵, 这个问题的确不好解决啊! 我想到一个办法:
Derive a class from CDateTimeCtrl, and over write its message function OnPaint(). In the OnPaint() function, you should do something funny:
(1) Define a BOOL variable that indicates whether the date is empty in your control;
(2) If you want it to be empty, change the BOOL variable, and cancel the executation of CDateTimeCtrl::OnPaint(), replacing it simply by the following code:
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
(3) If you want to keep the date significant in the control, please execute the only code:
CDateTimeCtrl::OnPaint();
You will see the following codes:
BOOL m_bEmptyDateTime;
if(m_bEmptyDateTime)
{
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
}
else
CDateTimeCtrl::OnPaint();
Derive a class from CDateTimeCtrl, and over write its message function OnPaint(). In the OnPaint() function, you should do something funny:
(1) Define a BOOL variable that indicates whether the date is empty in your control;
(2) If you want it to be empty, change the BOOL variable, and cancel the executation of CDateTimeCtrl::OnPaint(), replacing it simply by the following code:
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
(3) If you want to keep the date significant in the control, please execute the only code:
CDateTimeCtrl::OnPaint();
You will see the following codes:
BOOL m_bEmptyDateTime;
if(m_bEmptyDateTime)
{
CDC* pDC=GetDC();
pDC->Rectangle(...);
pDC->ReleaseDC();
}
else
CDateTimeCtrl::OnPaint();
#2
我试试看
#3
呵呵,这其实也是一个好方法,但这样子只是把时间隐藏了而已,但控件里面还是有时间
还有其它更好的方法不/