Delen via


CMonthCalCtrl::GetCalendarGridInfo

Retrieves information about the current month calendar control.

BOOL GetCalendarGridInfo(
     PMCGRIDINFO pmcGridInfo
) const;

Parameters

Parameter

Description

[out] pmcGridInfo

Pointer to a MCGRIDINFO structure that receives information about the current month calendar control. The caller is responsible for allocating and initializing this structure.

Return Value

true if this method is successful; otherwise, false.

Remarks

This method sends the MCM_GETCALENDARGRIDINFO 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 uses the GetCalendarGridInfo method to retrieve the calendar date that the current month calendar control displays.

    WCHAR name[26];
    name[0] = _T('\0');
    MCGRIDINFO gridInfo;
    gridInfo.cbSize = sizeof(MCGRIDINFO);
    gridInfo.dwPart = MCGIP_CALENDARHEADER;
    gridInfo.dwFlags = MCGIF_NAME;
    gridInfo.iCalendar = 0;
    gridInfo.pszName = reinterpret_cast<PWSTR>(&name);
    gridInfo.cchName = sizeof(name);

    m_monthCalCtrl.GetCalendarGridInfo( &gridInfo );

    CString str;
    CString calendarDate(name);
    str.Format(_T("Calendar date: '%s'"), calendarDate);
    AfxMessageBox(str, MB_ICONINFORMATION);

See Also

Reference

CMonthCalCtrl Class

Hierarchy Chart

MCM_GETCALENDARGRIDINFO

MCGRIDINFO

Other Resources

CMonthCalCtrl Members