Creating a Date and Time Picker Control

The date and time picker is a control that displays information about dates and times and provides users with an easy way to modify this information. Each field in the control displays a time element, such as month, day, hour, or minute. A user selects a field by tapping it with the stylus and then types a new value from the keyboard.

The way date and time information is displayed is determined by a format string. A date and time picker control can display time information in any of three preset formats, or you can create custom format strings to specify a different order in which to display the fields. You can also add customized date and time information to a date and time picker control by using callback fields.

    To create a date and time picker control

  1. Specify DATETIMEPICK_CLASS in the lpClassName parameter of the CreateWindowEx function.

    This class is registered when the common control DLL is loaded. You can use the InitCommonControls function to ensure that this DLL is loaded. To register the date and time picker class using the InitCommonControlsEx function, specify the ICC_DATE_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure you pass in the lpInitCtrls parameter.

  2. Specify a date and time picker style in the dwStyle parameter of the CreateWindowEx function. The following screen shot shows the Windows CE date and time picker.

    For a complete listing of supported styles, see Window and Control Styles.