HeaderPane
Main
Hide
Share Link
Print

View

Defines the view a month calendar control shows.

C

int WINAPI SftDate_GetView(HWND hwndCtl);
BOOL WINAPI SftDate_SetView(HWND hwndCtl, int view);

C++

int CSftCalendar::GetView() const;
BOOL CSftCalendar::SetView(int view);

Parameters

hwndCtl

The window handle of the month calendar control (SftCalendar).

view

The view, one of the values SFTDATE_VIEW_MONTH, SFTDATE_VIEW_YEAR, SFTDATE_VIEW_DECADE or SFTDATE_VIEW_CENTURY (see SetInitialView).

Returns

GetView returns the current view.

SetView returns TRUE if the view was set. FALSE is returned if view is not valid or not allowed (SetAllowedViews), or if hwndCtl is not a month calendar control.

Comments

The GetView and SetView functions define and retrieve the view of a month calendar control: the days of a month, the months of a year, the years of a decade or the decades of a century. The user switches views by clicking the title and by choosing a period. The control sends the NM_SFTDATE_VIEWCHANGED notification when the view changes.

SetInitialView defines the view the control starts with. This function applies to the month calendar control only. For a date field control, GetView returns SFTDATE_VIEW_MONTH and SetView has no effect and returns FALSE.

Examples

C View entire sample code

    case NM_SFTDATE_DROPDOWNCLOSED:
        lpszCode = TEXT("NM_SFTDATE_DROPDOWNCLOSED");
        break;
    case NM_SFTDATE_DATEACTIVATED:
        lpszCode = TEXT("NM_SFTDATE_DATEACTIVATED");
        wsprintf(szData, TEXT("date=%s"), FormatDate(&((LPSFTDATE_NMDATE) lpnmhdr)->date, TRUE, szDate1));
        break;
    case NM_SFTDATE_VIEWCHANGED: {
        int view = SftDate_GetView(lpnmhdr->hwndFrom);
        lpszCode = TEXT("NM_SFTDATE_VIEWCHANGED");
        lstrcpy(szValue, view >= 0 && view < 4 ? views[view] : TEXT("?"));
        break;
     }
    case NM_SFTDATE_DISPLAYCHANGED:
        lpszCode = TEXT("NM_SFTDATE_DISPLAYCHANGED");
        FormatDate(&st, SftDate_GetDisplayStart(lpnmhdr->hwndFrom, &st), szValue);

C++ View entire sample code

    case NM_SFTDATE_DROPDOWNCLOSED:
        code = _T("NM_SFTDATE_DROPDOWNCLOSED");
        break;
    case NM_SFTDATE_DATEACTIVATED:
        code = _T("NM_SFTDATE_DATEACTIVATED");
        data = _T("date=") + FormatDate(((LPSFTDATE_NMDATE) pNMHDR)->date, TRUE);
        break;
    case NM_SFTDATE_VIEWCHANGED: {
        int view = m_Calendar.GetView();
        code = _T("NM_SFTDATE_VIEWCHANGED");
        value = view >= 0 && view < 4 ? views[view] : _T("?");
        break;
     }
    case NM_SFTDATE_DISPLAYCHANGED:
        code = _T("NM_SFTDATE_DISPLAYCHANGED");
        value = FormatDate(st, m_Calendar.GetDisplayStart(&st));

See Also C/C++ API | Categories | Notifications


Last Updated 11/26/2026 - (email)
© 2026 Softel vdm, Inc.