Export (0) Print
Expand All

CMonthCalCtrl::SetCurSel

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 Platform SDK. In MFC's implementation of SetCurSel, you can specify a COleDateTime usage, a CTime usage, or a SYSTEMTIME structure usage.

Example

// All of these calls set the current selection to March 15, 1998.

void CDatesDlg::OnButton2() 
{
   // Gain a pointer to the control
   CMonthCalCtrl* pCtrl = (CMonthCalCtrl*) GetDlgItem(IDC_MONTHCALENDAR1);

   // with a COleDateTime
   COleDateTime dt1(1998, 3, 15, 0, 0, 0);
   pCtrl->SetCurSel(dt1);

   // with a CTime
   CTime dt2(1998, 3, 15, 0, 0, 0);
   pCtrl->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;

   pCtrl->SetCurSel(&sysTime);
}

See Also

CMonthCalCtrl Overview | Class Members | Hierarchy Chart | CMonthCalCtrl::GetCurSel

Show:
© 2014 Microsoft