CMonthCalCtrl::GetRange

更新 : 2007 年 11 月

月間予定表コントロールで使用できる日付の範囲を取得します。

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

パラメータ

  • pMinRange
    範囲の開始日付を示す、COleDateTime オブジェクトまたは CTime オブジェクトへの参照、あるいは SYSTEMTIME 構造体へのポインタ。

  • pMaxRange
    範囲の最終日付を受け取る COleDateTime オブジェクト、CTime オブジェクト、または SYSTEMTIME 構造体へのポインタ。

戻り値

DWORD を返します。範囲が設定されていない 0。範囲が指定されている場合には、以下の値が組み合わされます。

説明

GDTR_MAX

コントロールに最大値 (範囲の最終日付) が設定されています。pMaxRange で有効な日付情報が返されます。

GDTR_MIN

コントロールに最小値 (範囲の開始日付) が設定されています。pMinRange で有効な日付情報が返されます。

解説

このメンバ関数は、Windows SDK に説明されている Win32 のメッセージ「MCM_GETRANGE」の動作を実装します。MFC における GetRange の実装では、COleDateTime クラス、CTime クラス、または SYSTEMTIME 構造体が指定できます。

使用例

// 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 CMonthCalDlg::OnBnClickedRangebutton()
{
   // 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_calCtrl1.SetRange(&dtMin, &dtMax);
   ShowRange(&m_calCtrl1);

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

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

void CMonthCalDlg::ShowRange(CMonthCalCtrl* pMoCalCtrl)
{
   ASSERT(pMoCalCtrl != NULL);
   CString strMessage;
   COleDateTime dtMinimum;
   COleDateTime dtMaximum;

   // Get the range
   DWORD dwResult = pMoCalCtrl->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);
}

必要条件

ヘッダー : afxdtctl.h

参照

参照

CMonthCalCtrl クラス

階層図

CMonthCalCtrl::SetRange

その他の技術情報

CMonthCalCtrl のメンバ