COXDateTimeCtrl
Copyright © The Code Project 1997 1998, All Rights Reserved

A COXDateTimeCtrl object encapsulates the functionality of a date and time picker control. The date and time picker control (DTP control) provides a simple interface to exchange date and time information with a user. This interface contains fields, each of which displays a part of the date and time information stored in the control. The user can change the information stored in the control by changing the content of the string in a given field. The user can move from field to field using the mouse or the keyboard.

Using COXDateTimeCtrl

The date and time picker control (COXDateTimeCtrl) 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.

Note To use both the CDateTimePicker and COXMonthCalCtrl classes in your project, you must include OXDateTimeCtrl.h

Creating the Date and Time Picker Control

How the date and time picker control is created depends on whether you are using the control in a dialog box or creating it in a nondialog window.

To use COXDateTimeCtrl directly in a dialog box 

Visual C++ v6.0:
In the dialog editor, add a Date and Time Picker Control to your dialog template resource. Specify its control ID. Specify any styles required, using the Properties dialog box of the date and time picker control. Use ClassWizard to map handler functions in the dialog class for any date time picker control notification messages you need to handle. In OnInitDialog, set any additional styles for the COXDateTimeCtrl object. 

Visual C++ v5.0:
In the dialog editor, add a Static Control to your dialog template resource (it will be a placeholder for the DTP control). Specify its control ID. In OnInitDialog, you can use next code to replace Static Control on our DTP control:

	CWnd *pFrame=
		GetDlgItem(IDC_DATETIMEPICKER); 
	CRect rcWnd; 
	pFrame>GetWindowRect(rcWnd); 
	pFrame>DestroyWindow();
	ScreenToClient(rcWnd); 
	m_ctlDateTimePicker.
		Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP,
		rcWnd,this, IDC_DATETIMEPICKER);		

To use COXDateTimeCtrl in a nondialog window :

Declare the control in the view or window class. Call the control's Create member function, possibly in OnInitialUpdate, possibly as early as the parent window's OnCreate handler function (if you're subclassing the control). Set the styles for the control.