Microsoft KB Archive/224570

= UpDnDate.exe Implements a DateTime Control with a Spin Button and Callback Fields =

Article ID: 224570

Article Last Modified on 8/9/2004

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q224570



SUMMARY
UpDnDate.exe is a sample that demonstrates how the new DateTime picker control can be used in an MFC application. In addition to illustrating the code that needs to be written in order to use such a control with callback fields, the sample also shows how to handle notifications sent by the child spin button created when the DTS_UPDOWN style is specified for the date time control.



MORE INFORMATION
The following files are available for download from the Microsoft Download Center:

Visual C++ 6.0
Download Updndata.exe now

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Visual C++ .NET
Download Updndatevcnet.exe now

Release Date: July 2, 2002

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The code included is based on a Visual C++ version 6.0 AppWizard generated dialog based application. The points of interest are:
 * The datetime picker control inserted in the dialog template has the DTS_UPDOWN style.
 * The WM_INITDIALOG handler for the parent dialog defines the callback field, with a call to CDateTimeCtrl::SetFormat.
 * The CDateTimeCtrl-derived class CUDDateTimeCtrl implements handlers for the relevant reflected notifications: DTN_FORMAT, DTN_FORMATQUERY, DTN_WMKEYDOWN, following the guidelines from the online help.
 * CUDDateTimeCtrl implements a handler for the UDN_DELTAPOS notification, sent to the date time control by the child spin button (created due to the DTS_UPDOWN style).
 * CUDDateTimeCtrl::OnNotifyDeltaPos cannot identify the field that has the focus. To work around this, the control sends a WM_KEYDOWN and WM_KEYUP message (with VK_UP or VK_DOWN as arguments) to itself.
 * CUDDateTimeCtrl::OnNotifyDeltaPos shortcuts the default implementation, even for the standard fields of the control. Instead, it posts WM_KEYDOWN, WM_KEYUP messages to the control. This is done in order to work around a bug that exists in the date time picker common control shipped with Internet Explorer 4.0 (comctl32.dll version 4.70-4.72). The bug is fixed in the Internet Explorer 5.0 release (comctl32.dll version 5.00).

To see the control in action, build the project and run it. Set the focus to the custom field and either press the up or down arrow keys or use the mouse to click on the up or down buttons of the spin control. You'll see that all fields of the date time control are updated as expected.

Additional query words: DateTimePicker UpDnDate

Keywords: kbdownload kbupdownctrl kbdatetime kbuidesign kbfile kbsample kbctrl KB224570

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.