This article was previously published under Q259460
This article has been archived. It is offered "as is" and will no longer be updated.
When you use the Date Time Picker control on a Web page, depending on the security level set in Internet Explorer, Internet Explorer may display the following warning message:
An ActiveX object on this page may be unsafe. Do you want to allow it to be initialized and accessed by scripts?
NOTE: Controls that are inherited from the Date Time Picker may also encounter this problem. For example, the Month View control that comes with MSCOMCTL2.cab is marked as unsafe for initialization and scripting in Internet Explorer 5.0 and 5.5 because it depends on the Date Time Picker control. Other custom controls that are extended from this control may also encounter this problem in which the control is marked as unsafe for scripting.
Date Timer Picker was incorrectly marked as unsafe for scripting. However, it is safe for initialization.
By default, Internet Explorer is configured to disable scripting to an ActiveX control that is not marked safe for scripting. (To change this setting, go to Control Panel, double-click Internet Options, and click the Security tab.)
To overcome this problem, wrap Date Time Picker in your own control and expose the appropriate properties and interfaces. Mark it safe by implementing IObjectSafety. See the "More Information" section of this article for detailed information on how to do this.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Here are the steps that you can to take to simplify the process of wrappingDate Time Picker control in Visual Basic.
Create a new ActiveX control project.
From the Projects menu, select Components to add the Microsoft Windows Common Controls-2 6.0 Service Pack 3 (MScomctl.ocx).
Click the Date Time Picker control and drag it to your user control. You can resize the control so it fits exactly.
Use the object browser to note what methods, events, and properties that you want exposed from the Date Time Picker control.
Start the Visual Basic 6 ActiveX Control Interface Wizard. If the Wizard is not listed under the Visual Basic Add-Ins menu, use the Add-In Manager to load it. You can find documentation for the ActiveX Control Interface Wizard in Visual Basic Help.
Select the methods, events, and properties that you are want to expose from the Date Time Picker control.
On the next screen, add custom members that you want for your control; otherwise leave it blank.
On the next screen, map each of the names that you selected in your first screen to the respective control. The public name is what the users will use. Internally, you can map it to the Date Time Picker or your control.
For example, font is a stock property that might be exposed by both the Date Time Picker control as well as your control. Internally, you can just use the Date Time's property. If you want to support it from both your control and the Date Time Picker control, you must add a new property in your control and call the Date Time Control's property internally.
The Wizard will then generate all the code for you. You can do all of this manually, but it's easier to use the Wizard.
Besides wrapping the control, you must also implement theIObjectSafety interface for your control. Information on how to do this is in the following Microsoft Knowledge Base article:
182598 HowTo: Implement IObjectSafety in Visual Basic Controls
NOTE: If you have problems with Mktyplib at this step, it may be because it is missing the MSpdb60.dll file. Copy this file from your Visual Basic 6 CD-ROM to the same folder where the Mktyplib utility is installed. Double-click Mktyplib.exe, and it should prompt you for the .odl file as described in Knowledge Base article Q182598.