Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.
Source code and project files for this sample can be found in the samples\gui\DateTimePicker directory of the sample projects download.
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.
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
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 non-dialog 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
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 the following code to replace the Static control with our DTP control:
CWnd *pFrame= GetDlgItem(IDC_DATETIMEPICKER);
To Use COXDateTimeCtrl in a Non-Dialog Window
Declare the control in the view or the 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). You can then set the styles for the control.
COXDateTimeCtrl class reference in the Graphical User Interface section of the compiled HTML help for a description of the member functions available for setting and retrieving data from the control.
Initial CodeProject release August 2007.
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.
Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.