Knowledge Base

How to implement a Date/Time generic ActiveX property page in Visual C++

Article ID: 207088

Article Last Modified on 1/10/2006


APPLIES TO


This article was previously published under Q207088

SUMMARY

Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model.

The DateTimePropPage.exe sample shows how to create a Date/Time Generic ActiveX Property Page by using ATL.

When developing an ActiveX control, it is a common practice to include a property page or pages to facilitate setting design-time properties. When the ActiveX control has a certain type of property (for example, OLE_COLOR), it makes sense to save time and use the stock property pages provided by Microsoft.

However, if there isn't a stock property page for the property you are working with and you know that you could use such a property page several times, it might be more efficient to create a single property page that can be re-used when needed.

MORE INFORMATION

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

Visual C++ 6.0

Release Date: Jan-21-2000

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

The following file is available for download from the Microsoft Download Center:
Release Date: June 24, 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. ATL allows you to use the property page for an ATL ActiveX control without having to move the MFC DLL.

This ATL project contains two projects: A Month Calendar control and Date Time control are added to the property page dialog box resource of the DateTimePropPage project. This resource is displayed when the property page is invoked. Notification handlers are added to the CDateTime class to handle the case where the date or time are changed through the dialog box controls. Thus, SetDirty(TRUE) can be called, which causes the Apply button to be activated on the property sheet that hosts the property page.

The key functions in the implementation of this project are OnInitDialog, Apply, GetProperties, and SetProperties, which are described below:
The ActiveX control supplied with this sample shows how to use the property page. The ActiveX control has two properties, DATE and TIME. Another ActiveX control that uses the standard Date/Time property page just needs to add a DATE and TIME property to the ActiveX control. These properties must be of the DATE data type.

Additional query words: Datetimeproppage Datetimeproppagevcnet

Keywords: kbhowto kbpropsheet kbfile kbctrlcreate kbsample KB207088