Partager via


CMonthCalCtrl::GetCurrentView

Retrieves the view that is currently displayed by the current month calendar control.

DWORD GetCurrentView() const;

Return Value

The current view, which is indicated by one of the following values:

Value

Meaning

MCMV_MONTH

Monthly view

MCMV_YEAR

Annual view

MCMV_DECADE

Decade view

MCMV_CENTURY

Century view

Remarks

This method sends the MCM_GETCURRENTVIEW message, which is described in the Windows SDK.

Requirements

Header: afxdtctl.h

This control is supported in Windows Vista and later.

Additional requirements for this method are described in Build Requirements for Windows Vista Common Controls.

Example

The following code example defines the variable, m_monthCalCtrl, that is used to programmatically access the month calendar control. This variable is used in the next example.

    // Variable used to reference the month calendar control.
    CMonthCalCtrl m_monthCalCtrl;
    // Variable used to reference the splitbutton control.
    CSplitButton m_splitButton;

The following code example reports which view the month calendar control currently displays.

   CString str;
    CString msg = _T("The current calendar displays %s view.");
    DWORD view = m_monthCalCtrl.GetCurrentView();
    switch (view) {
        case MCMV_MONTH:
            str.Format(msg, _T("month"));
            break;
        case MCMV_YEAR:
            str.Format(msg, _T("year"));
            break;
        case MCMV_DECADE:
            str.Format(msg, _T("decade"));
            break;
        case MCMV_CENTURY:
            str.Format(msg, _T("century"));
            break;
        default:
            str.Format(msg, _T("an unknown"));
            break;
    }
    AfxMessageBox(str, MB_ICONINFORMATION);

See Also

Reference

CMonthCalCtrl Class

Hierarchy Chart

MCM_GETCURRENTVIEW

CMonthCalCtrl::SetCurrentView