How to Process the DTN_DATETIMECHANGE Notification

This topic demonstrates how to process notification of changes, made by the user, to the date and time picker (DTP) control.

What you need to know

Technologies

Prerequisites

  • C/C++
  • Windows User Interface Programming

Instructions

A DTP control sends the DTN_DATETIMECHANGE notification code whenever a change occurs. For example, this notification will be generated when the user changes one of the fields in the control or, in the case where the control is set to the DTS_SHOWNONE style, when the user changes the state of the control's check box.

Your application must include code to process DTN_DATETIMECHANGE messages that are sent by the DTP control.

The following C++ code example is an application-defined function designed to indicate the state of a DTP control that is set to the DTS_SHOWNONE style.

void WINAPI DoDateTimeChange(LPNMDATETIMECHANGE lpChange)
{
    // If the user has unchecked the DTP's check box, change the
    // text in a static control to show the appropriate message.
    //
    // g_hwndDlg - a program-global address of a dialog box.

    if(lpChange->dwFlags == GDT_NONE)
        SetDlgItemText(g_hwndDlg, IDC_STATUS, L"Disabled");
    else
        SetDlgItemText(g_hwndDlg, IDC_STATUS, L"Active");
}

Using Date and Time Picker Controls

Date and Time Picker Control Reference

Date and Time Picker