DWORD GetRange( COleDateTime* pMinRange, COleDateTime* pMaxRange ) const;
DWORD GetRange( CTime* pMinRange, CTime* pMaxRange ) const;
DWORD GetRange( LPSYSTEMTIME pMinRange, LPSYSTEMTIME pMaxRange ) const;
Return Value
A DWORD that can be zero (no limits are set) or a combination of the following values that specify limit information.
Value | Meaning |
GDTR_MAX | A maximum limit is set for the control; pMaxRange is valid and contains the applicable date information. |
GDTR_MIN | A minimum limit is set for the control; pMinRange is valid and contains the applicable date information. |
Parameters
pMinRange
A pointer to a COleDateTime object, a CTime object, or SYSTEMTIME structure containing the date at the lowest end of the range.
pMaxRange
A pointer to a COleDateTime object, a CTime object, or SYSTEMTIME structure containing the date at the highest end of the range.
Remarks
This member function implements the behavior of the Win32 message MCM_GETRANGE, as described in the Platform SDK.
In MFC's implementation of GetRange, you can specify a COleDateTime usage, a CTime usage, or a SYSTEMTIME structure usage.
Example
// This code fragment sets a variety of ranges in the
// control, and calls a separate function to show the
// set range to the user.
void CDatesDlg::OnButton2()
{
// Gain a pointer to the control
CMonthCalCtrl* pCtrl = (CMonthCalCtrl*) GetDlgItem(IDC_MONTHCALENDAR1);
ASSERT(pCtrl != NULL);
// set minimum of January 1st, 1995 with no maximum
COleDateTime dtMin;
COleDateTime dtMax;
dtMin = COleDateTime(1995, 1, 1, 0, 0, 0);
dtMax.SetStatus(COleDateTime::null);
pCtrl->SetRange(&dtMin, &dtMax);
ShowRange(pCtrl);
// set no minimum and a maximum of September 30th, 1997
dtMin.SetStatus(COleDateTime::null);
dtMax = COleDateTime(1997, 9, 30, 0, 0, 0);
pCtrl->SetRange(&dtMin, &dtMax);
ShowRange(pCtrl);
// set minimum of April 15, 1992 and maximum of June 5, 2002
dtMin = COleDateTime(1992, 4, 15, 0, 0, 0);
dtMax = COleDateTime(2002, 6, 5, 0, 0, 0);
pCtrl->SetRange(&dtMin, &dtMax);
ShowRange(pCtrl);
}
void CDatesDlg::ShowRange(CMonthCalCtrl* pCtrl)
{
ASSERT(pCtrl != NULL);
CString strMessage;
COleDateTime dtMinimum;
COleDateTime dtMaximum;
// Get the range
DWORD dwResult = pCtrl->GetRange(&dtMinimum, &dtMaximum);
// If a minimum was specified, format it
// otherwise, indicate that there is no lower bound
if (dwResult & GDTR_MIN)
strMessage += dtMinimum.Format(_T("Minimum range is %x %X.\r\n"));
else
strMessage += _T("No minimum range.\r\n");
// Treat maximum similarly
if (dwResult & GDTR_MAX)
strMessage += dtMaximum.Format(_T("Maximum range is %x %X.\r\n"));
else
strMessage += _T("No maximum range.\r\n");
// Show the user
AfxMessageBox(strMessage);
}
CMonthCalCtrl Overview | Class Members | Hierarchy Chart
See Also CMonthCalCtrl::SetRange