CDateTimeCtrl::GetRange

日時指定コントロールの現在の最小値と最大値によって認められるシステム時刻を取得します。

DWORD GetRange(
   COleDateTime* pMinRange,
   COleDateTime* pMaxRange 
) const;
DWORD GetRange(
   CTime* pMinRange,
   CTime* pMaxRange 
) const;

パラメーター

  • pMinRange
    最も早い時刻を含む CDateTimeCtrl のオブジェクトで COleDateTime のオブジェクトまたは CTime のオブジェクトへのポインターを使用できる。

  • pMaxRange
    最新の時刻を含む CDateTimeCtrl のオブジェクトで COleDateTime のオブジェクトまたは CTime のオブジェクトへのポインターを使用できる。

戻り値

どの範囲が設定されているかを示すフラグを含む DWORD の値。If

return value & GDTR_MAX == 0

次に、2 番目のパラメーターで有効です。同様に、

return value & GDTR_MIN == 0

その後、最初のパラメーターで有効です。

解説

このメンバー関数は Windows SDKに記述されている Win32 メッセージの動作を DTM_GETRANGE実行します。MFC 実装では、COleDateTimeCTime の使用方法を指定できます。

使用例

// This function will set several ranges in the control, then
// call the ShowRange() function to show the set ranges to the
// user.
void CDateTimeDlg::OnBnClickedRangesbutton()
{
   // 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);
   m_DateTimeCtrl.SetRange(&dtMin, &dtMax);
   ShowRange(&m_DateTimeCtrl);

   // Set no minimum and maximum of September 30th, 1997.
   dtMin.SetStatus(COleDateTime::null);
   dtMax = COleDateTime(1997, 9, 30, 0, 0, 0);
   m_DateTimeCtrl.SetRange(&dtMin, &dtMax);
   ShowRange(&m_DateTimeCtrl);

   // 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);
   m_DateTimeCtrl.SetRange(&dtMin, &dtMax);
   ShowRange(&m_DateTimeCtrl);
}

void CDateTimeDlg::ShowRange(CDateTimeCtrl* 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);
}

必要条件

Header: afxdtctl.h

参照

関連項目

CDateTimeCtrl クラス

階層図

CDateTimeCtrl::SetRange