Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Sets the currently selected date for a month calendar control.
BOOL SetCurSel(
const COleDateTime& refDateTime
);
BOOL SetCurSel(
const CTime& refDateTime
);
BOOL SetCurSel(
const LPSYSTEMTIME pDateTime
);
Parameters
refDateTime
A reference to a COleDateTime or CTime object indicating the currently-selected month calendar control.pDateTime
Pointer to a SYSTEMTIME structure that contains the date to be set as the current selection.
Return Value
Nonzero if successful; otherwise 0.
Remarks
This member function implements the behavior of the Win32 message MCM_SETCURSEL, as described in the Windows SDK. In MFC's implementation of SetCurSel, you can specify a COleDateTime usage, a CTime usage, or a SYSTEMTIME structure usage.
Example
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);
}
Requirements
Header: afxdtctl.h