上图为实现的效果图。
首先自定义一个类CMFCPropertyGridDateTimeProperty,基类是CMFCPropertyGridProperty。
class CMFCPropertyGridDateTimeProperty :
public CMFCPropertyGridProperty
{
DECLARE_DYNAMIC(CMFCPropertyGridDateTimeProperty)
public:
CMFCPropertyGridDateTimeProperty(const CString& strName, const CString& dtDateTime, LPCTSTR lpszDescr = _T(""), BOOL isDate=TRUE);
virtual ~CMFCPropertyGridDateTimeProperty();
// Overrides
public:
virtual BOOL OnClickValue(UINT uiMsg, CPoint point); //鼠标点击属性列表“值”的区域触发此函数
CInnerDateTimeCtrl *m_dtCtrl; //自定义CDateTimeCtrl类
// Attributes
protected:
BOOL m_bIsDate; //TRUE: 日期类型; FALSE: 时间