创建一个类CMFCPropertyGridDateTimeProperty,继承自CMFCPropertyGridProperty
/////////////////////////////////////.h////////////////////////////////////////
// CMFCPropertyGridDateTimeProperty object
//QQ:20794027
//Name:zhaogaojian
class CMFCPropertyGridDateTimeProperty : public CMFCPropertyGridProperty
{
DECLARE_DYNAMIC(CMFCPropertyGridDateTimeProperty)
// Construction
public:
CMFCPropertyGridDateTimeProperty(const CString& strName, const CString& dtDateTime, DWORD_PTR dwData = 0, LPCTSTR lpszDescr = NULL,BOOL isDate=TRUE);
virtual ~CMFCPropertyGridDateTimeProperty();
// Overrides
public:
virtual void OnClickButton(CPoint point);
// Attributes
protected:
BOOL m_bIsDate;
CString m_strDateTime;
};
// MyPropertyGridProperty.cpp : 实现文件
//
#include "stdafx.h"
#include "LCMeterSetCOM.h"
#include "MyPropertyGridProperty.h"
#include "MyDateDialog.h"
/////////////////////////////////////.cpp////////////////////////////////////////
// CMFCPropertyGridDateTimeProperty object
#define AFX_PROP_HAS_LIST 0x0001
#define AFX_PROP_HAS_BUTTON 0x0002
#define AFX_PROP_HAS_SPIN 0x0004
IMPLEMENT_DYNAMIC(CMFCPropertyGridDateTimeProperty, CMFCPropertyGridProperty)
CMFCPropertyGridDateTimeProperty::CMFCPropertyGridDateTimeProperty(const CString& strName, const CString& strDateTime, DWORD_PTR dwData, LPCTSTR lpszDescr,BOOL isDate) : CMFCPropertyGridProperty(strName, COleVariant(strDateTime), lpszDescr, dwData)
{
m_dwFlags = AFX_PROP_HAS_BUTTON;
AllowEdit(false);
m_bIsDate=isDate;
}
CMFCPropertyGridDateTimeProperty::~CMFCPropertyGridDateTimeProperty()
{
}
void CMFCPropertyGridDateTimeProperty::OnClickButton(CPoint /*point*/)
{
ASSERT_VALID(this);
ASSERT_VALID(m_pWndList);
ASSERT_VALID(m_pWndInPlace);
ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd()));
m_bButtonIsDown = TRUE;
Redraw();
//CString
CString strDate;
COleDateTime m_dtDateTime;
m_dtDateTime = m_varValue.date;
BOOL bUpdate = FALSE;
CDateTimeCtrl m_dtCtrl;
CMyDateDialog dlg;
if (dlg.DoModal() == IDOK)
{
bUpdate = TRUE;
if(m_bIsDate)
strDate.Format("%04d-%02d-%02d",dlg.m_dtDatePicker.GetYear(),dlg.m_dtDatePicker.GetMonth(),dlg.m_dtDatePicker.GetDay());
else
strDate.Format("%02d:%02d:%02d",dlg.m_dtTimePicker.GetHour(),dlg.m_dtTimePicker.GetMinute(),dlg.m_dtTimePicker.GetSecond());
//strPath = dlg.GetPathName();
}
if (bUpdate)
{
if (m_pWndInPlace != NULL)
{
m_pWndInPlace->SetWindowText(strDate);
}
m_varValue = (LPCTSTR) strDate;
}
m_bButtonIsDown = FALSE;
Redraw();
if (m_pWndInPlace != NULL)
{
m_pWndInPlace->SetFocus();
}
else
{
m_pWndList->SetFocus();
}
}
CMyDateDialog 是一个继承自dialog的类,里边有两个日期控件,变量名分别为m_dtDatePicker,m_dtTimePicker
使用方法:
...
apGroup1->AddSubItem(new CMFCPropertyGridDateTimeProperty(_T("日期"), strDate, 71 ,"请选择日期",TRUE));
...
LRESULT CPropertiesViewBar::OnPropertyChanged (WPARAM wParam,LPARAM lParam)
{
CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*) lParam;
BOOL bResetMDIChild = FALSE;
CString str;
int iYear=0,iMonth=0,iDay=0,iHour=0,iMinute=0,iSecond=0;
int iData=(int) pProp->GetData ();
switch (iData)
{
当更新数据时,再将字符串转成COleDateTime;
相关推荐
A fully customizable PropertyGrid vc6版本,实现了类似vb6属性页风格的控件,使用非常方便,可以直接添加各类控件
创建一个类CMFCPropertyGridDateTimeProperty,继承自CMFCPropertyGridProperty,让VC2010的CMFCPropertyGridProperty支持日期选择
一个用VC 编写的窗口 属性参数编辑控件源码,PropertyGrid面板程序,大家一看就知道是什么程序,用来设置参数用的,类似VC IDE窗口环境的属性窗口的功能,这个属性编辑器可对显示在Grid中的各个参数行进行分类和排序...
Select日期下拉选择器,年、月、日联动显示,准确显示日期(包括闰年日期),可自定义日期范围。这个看个人习惯了,有的用的是JS日历插件。
VC实现的下拉树 功能是进行磁盘目录选择 visual assist
VC 可拖放的ListBox下拉列表框,不使用OLE即可实现,直接对列表内的多个内容进行拖动,代码只是一个类的代码,没有包括例子,自己好好研究下吧。
VC.NET2005_ComboBox下拉列表框。包括2个实例,一个work文档资料。
VC 带图像的下拉列表框,对学习有所帮助.
一个类似于日期选择功能的VC 时间计算程序,在开始时间中选择日期,结束时间中选择日期,点击确定后会计算出两者的时间差,之前的代码由国外网友提供,现已汉化。对于日期时间的计算,有不少朋友觉得有些难度,其实...
VC 在组合框的下拉列表框中实现自动选择,当在Combobox组合框中键入字符时,组合框会根据用户的输入在列表框中自动选择匹配的项,其实就是大家熟悉的搜索提示,用户输入时,Combobox下拉框会智能匹配用户的输入内容...
创建一个类CMFCPropertyGridDateTimeProperty,继承自CMFCPropertyGridProperty,用月历控件让VC2010的CMFCPropertyGridProperty支持日期选择.
本例演示在程序中如何创建类似IE工具栏中带下拉箭头按钮的工具栏
visual c++实现工具栏的下拉箭头按钮
VC中在EDIT中做日期选择,源代码,自己可以浏览
vc2010运行库x64 x86 vc2010运行库x64 x86 vc2010运行库x64 x86
VC 6.0 日期选择-VC日历调用,在程序中调用Calendar日历组件,让用户快速选择时间日期,通过这种嵌入的日历选择器,用户可方便选取日期时间,同时也可减少程序对手动输入时间的校验,提升输入效率。
vc工具栏中实现下拉列表,并代有按钮,可以扩展出其它控件,
支持vc 2010 和vc 2008 是最新的 vc助手插件
VC增强Edit控件为日期输入控件,文档,代码!!
vc2010编译器,只支持c++/c,不带mfc和debug库