Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
The date and time picker control (CDateTimeCtrl) implements an intuitive and recognizable method of entering or selecting a specific date. The main interface of the control is similar in functionality to a combo box. However, if the user expands the control, a month calendar control appears (by default), allowing the user to specify a particular date. When a date is chosen, the month calendar control automatically disappears.
Sr.No.
Name & Description
1
CloseMonthCal
Closes the current date and time picker control.
2
Create
Creates the date and time picker control and attaches it to the CDateTimeCtrl object.
3
GetDateTimePickerInfo
Retrieves information about the current date and time picker control.
4
GetIdealSize
Returns the ideal size of the date and time picker control that is required to display the current date or time.
5
GetMonthCalColor
Retrieves the color for a given portion of the month calendar within the date and time picker control.
6
GetMonthCalCtrl
Retrieves the CMonthCalCtrl object associated with the date and time picker control.
7
GetMonthCalFont
Retrieves the font currently used by the date and time picker control's child month calendar control.
8
GetMonthCalStyle
Gets the style of the current date and time picker control.
9
GetRange
Retrieves the current minimum and maximum allowed system times for a date and time picker control.
10
GetTime
Retrieves the currently selected time from a date and time picker control and puts it in a specified SYSTEMTIME structure.
11
SetFormat
Sets the display of a date and time picker control in accordance with a given format string.
12
SetMonthCalColor
Sets the color for a given portion of the month calendar within a date and time picker control.
13
SetMonthCalFont
Sets the font that the date and time picker control's child month calendar control will use.
14
SetMonthCalStyle
Sets the style of the current date and time picker control.
15
SetRange
Sets the style of the current date and time picker control.
16
SetTime
Sets the time in a date and time picker control.
Let us look into a simple example by creating a new MFC application.
Step 1 − Remove the Caption and set its ID to IDC_STATIC_TXT.
Step 2 − Add the value variable for text control.
Step 3 − Drag the Date Time Picker control.
Step 4 − Add a control variable for Date Time Picker.
Step 5 − Add the Event handler for Date Time Picker.
Step 6 − Here is the implementation of event handler.
void CMFCDateAndTimePickerDlg::OnDtnDatetimechangeDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult){
LPNMDATETIMECHANGE pDTChange = reinterpret_cast <LPNMDATETIMECHANGE>(pNMHDR);
// TODO: Add your control notification handler code here
GetDlgItemText(IDC_DATETIMEPICKER1, m_strValue);
UpdateData(FALSE);
*pResult = 0;
}
Step 7 − When you run the above application, you see the following output. Select any date, it will display on the Static Text Control.