PRB: Dynamic Creation of Redistributable Control FailsLast reviewed: February 17, 1998Article ID: Q151804 |
The information in this article applies to:
SYMPTOMSAttempting to dynamically create an instance of one of the redistributable ActiveX controls supplied with Visual C++ fails on machines where Visual C++ has not been installed. However, creating an instance of the same control on a dialog box succeeds.
CAUSEThe redistributable controls supplied with Visual C++ are licensed.
RESOLUTIONSpecify a valid License string when dynamically creating the control.
STATUSThis behavior is by design.
MORE INFORMATIONWhen Visual C++ is installed on a machine, the entire machine becomes licensed to use the redistributable ActiveX controls as part of the installation process. If an instance of one of the redistributable controls is created dynamically and no License key is specified, the creation will succeed because the control is able to determine that the entire machine is licensed and so will allow itself to be created. However, if the same code that performs the dynamic creation of the control is executed on a machine that has not had Visual C++ installed on it (such as Visual Basic or another application that provides the same control), the creation will fail. In this case the control will not allow itself to be created if a License key is not specified and the machine has not been licensed. The CWnd::CreateControl method can be used to dynamically create an instance of an ActiveX control. When an ActiveX control is inserted into a Visual C++ project via the Component Gallery, a wrapper class is created that can be used to work with the control. The wrapper class provides two overridden versions of the Create method. One of the versions allows a string to be passed that will be used as the License key when creating the control; the other version does not. Dynamic creation of one of the redistributable ActiveX controls will fail on a machine that has not had Visual C++ installed on it if any of the following methods are used to create the control:
To allow a licensed control to be dynamically created on a machine that is not licensed requires passing a License key. An application that performs dynamic creation of a control must have the control's License key cached in its own code. This must be done while the application is being designed. For sample code illustrating how to request a License key from an object, refer to the following article in the Microsoft Knowledge Base:
ARTICLE ID: Q151771 TITLE : SAMPLE: LicReqst Shows Requesting a License Key from an ObjectThe following redistributable controls supplied with Visual C++ 4.1 are licensed and require a License key to be dynamically created on machines that have not had Visual C++ installed:
Control File Description ------------------------------------------- anibtn32.ocx Animated button Control keysta32.ocx Key Status Control mci32.ocx Multimedia MCI Control mscomm32.ocx Communications Control msmask32.ocx Masked Edit grid32.ocx Grid Control picclp32.ocx Picture Clip Control REFERENCESFor more information, please see: The Visual C++ documentation on the CWnd::CreateControl method. The Visual C++ documentation on licensing an OLE control. The Visual C++ documentation on using controls in a non-dialog container. The OLE Programmer's Reference documentation on the IClassFactory2 interface.
|
Additional reference words: ocx cdk
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |