CMonthCalCtrl::SetDayState

将显示在月历控件的日。

BOOL SetDayState(
   int nMonths,
   LPMONTHDAYSTATE pStates 
);

参数

  • nMonths
    值指示某个元素在 pStates 指向的数组。

  • pStates
    用于定义的 MONTHDAYSTATE 的指针值month calendar控件在其显示每天将绘制。 MONTHDAYSTATE 数据类型是位域,每位(1到31)在一个月份表示一天状态。 如果位打开,对应的日以粗体显示;否则它将显示没有焦点。

返回值

非零,如果成功;否则为0。

备注

此成员函数实现Win32消息 MCM_SETDAYSTATE的行为,如 Windows SDK所述。

示例

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;
}

要求

Header: afxdtctl.h

请参见

参考

CMonthCalCtrl选件类

层次结构图