次の方法で共有


CMonthCalCtrl::SetDayState

更新 : 2007 年 11 月

月間予定表コントロールの日付表示を設定します。

BOOL SetDayState(
   int nMonths,
   LPMONTHDAYSTATE pStates 
);

パラメータ

  • nMonths
    pStates が指す配列の要素数を示す値。

  • pStates
    月間予定表コントロールの各日付の表示方法を示す MONTHDAYSTATE 配列へのポインタ。MONTHDAYSTATE データ型はビット フィールドです。ビット 1 から 31 によって各日付の状態を示します。ビットがオンになっている場合、対応する日付が太字で表示されます。ビットがオフになっている場合は、太字で表示されません。

戻り値

正常終了した場合は 0 以外を返します。それ以外の場合は 0 を返します。

解説

このメンバ関数は、Windows SDK に記述されている Win32 メッセージ MCM_SETDAYSTATE の動作を実装します。

使用例

void CMonthCalDlg::OnBnClickedDaystatebutton()
{
   // First, we must find the visible range. The array we pass to the
   // SetDayState() function must be large enough to hold days for all
   // of the visible months. Even if a month is _partially_ visible,
   // we must have MONTHDAYSTATE data for it in the array we pass.
   // GetMonthRange() returns the range of days currently visible in
   // the control, along with a count of visible months. This array
   // will be up to 2 months larger than the number of "pages" visible
   // in the control.

   SYSTEMTIME timeFrom;
   SYSTEMTIME timeUntil;
   int nCount = m_calCtrl1.GetMonthRange(&timeFrom, &timeUntil, GMR_DAYSTATE);

   // Allocate the state array based on the return value.

   LPMONTHDAYSTATE pDayState;
   pDayState = new MONTHDAYSTATE[nCount];
   memset(pDayState, 0, sizeof(MONTHDAYSTATE) * nCount);

   // Find the first fully visible month.

   int nIndex = (timeFrom.wDay == 1) ? 0 : 1;

   // Set the 4th day, 19th day, and 26th day of the first
   // _fully_ visible month as bold.

   pDayState[nIndex] |= 1 << 3;   // 4th day
   pDayState[nIndex] |= 1 << 18;   // 19th day
   pDayState[nIndex] |= 1 << 25;   // 25th day

   // Set state and clean up

   VERIFY(m_calCtrl1.SetDayState(nCount, pDayState));
   delete [] pDayState;
}

必要条件

ヘッダー : afxdtctl.h

参照

参照

CMonthCalCtrl クラス

階層図

その他の技術情報

CMonthCalCtrl のメンバ