CMonthCalCtrl::SetCurSel
设置month calendar控件的当前选定的日期。
BOOL SetCurSel(
const COleDateTime& refDateTime
);
BOOL SetCurSel(
const CTime& refDateTime
);
BOOL SetCurSel(
const LPSYSTEMTIME pDateTime
);
参数
refDateTime
为指示当前选定的month calendar控件的 COleDateTime 或 CTime 对象的引用。pDateTime
对包含为当前选择要设置的该日期的 SYSTEMTIME 结构的指针。
返回值
非零,如果成功;否则为0。
备注
此成员函数实现Win32消息 MCM_SETCURSEL的行为,如 Windows SDK所述。 在 SetCurSel的MFC的实现,可以指定 COleDateTime 使用、 CTime 使用或 SYSTEMTIME framework使用。
示例
void CMonthCalDlg::OnBnClickedCurselbutton()
{
// All of these calls set the current selection to March 15, 1998.
// with a COleDateTime
COleDateTime dt1(1998, 3, 15, 0, 0, 0);
m_calCtrl1.SetCurSel(dt1);
// with a CTime
CTime dt2(1998, 3, 15, 0, 0, 0);
m_calCtrl1.SetCurSel(dt2);
// with a SYSTEMTIME structure
SYSTEMTIME sysTime;
// set everything to zero
memset(&sysTime, 0, sizeof(sysTime));
// except for the date we want
sysTime.wYear = 1998;
sysTime.wMonth = 3;
sysTime.wDay = 15;
m_calCtrl1.SetCurSel(&sysTime);
}
要求
Header: afxdtctl.h