INFO: OLE Control Licensing in Visual FoxPro

This article was previously published under Q139154
This article has been archived. It is offered "as is" and will no longer be updated.
SUMMARY
Visual FoxPro will not allow an OLE Control to be created or instantiatedunless the correct license is present. Developers who purchase and installan OLE Control as well as its license will be able to add this control toforms.

License information is saved with the form or class. This allowsdistributed forms to run successfully on workstations that do not have adesign-time license. Users are not able to open these forms formodification unless they also purchase a design time license from thecontrol's vendor.

Developers may also distribute visual class libraries that contain OLEcontrols. New controls based on these visual classes may be added torunning forms. Users may not modify these visual classes, add new controlsbased on them to forms in design mode, or subclass them.
MORE INFORMATION
OLE controls may be developed and distributed without charge or licensingrequirements. However, most will be designed so that they fail without alicense. There are currently two types of licenses for OLE controls:design-time and run-time.

  • A design-time license allows you to create new OLE Controls.
  • A run-time license allows you run a form that contains an OLE control.
The remainder of this article describes the most common licensingscheme used. However, control vendors are not required to follow thisscheme.

Controls may require no licenses or may supply design-time or run-timelicenses only.

Controls may check for license information in a manner other than describedhere. Refer to the OLE control's documentation for more information.

A license is a key or a value that a control can check by looking in theregistry or the container application. When you attempt to add an OLEcontrol such as the Outline control to a new form, the Outline controlchecks the registry for its design-time license key. If it finds this key,the new control is added.

When you save that form, Visual FoxPro requests the second type of key,the run-time license key, from the control. This second value is stored inthe form. When the form is run, Visual FoxPro passes the run-time key tothe control as it instantiates the form. This prevents the control fromchecking for a design-time key. This form will run on any workstation wherethe Outline control is installed, regardless of the existence of a design-time key.

The design-time license is a key in the registry of the workstation. It isgenerally placed there by the installation program that installed the OLEcontrol. However, vendors may supply a .reg file that can be merged intothe registry instead.

Four Step-by-Step Examples

The following examples demonstrate how OLE controls may be used in VisualFoxPro applications and how they can be successfully distributed. Theseexamples use the Outline control, which is shipped with the professionalversion of Visual FoxPro 3.0. The following examples are included:

  • Distributing a form that contains an Outline control.
  • Distributing a visual class that contains an Outline control.
  • Distributing a program that tries to create a new OLE control.
  • Distributing a program that creates a new OLE control from a class.
These examples use two example workstations called DevMachine andUserMachine that have been set up by using these steps:

  1. On DevMachine, install the Outline control and its design-time license, and register the Outline control for the Form Control toolbox. To do this:

    1. On the Tools menu, click Options, and then click the Control tab.
    2. Select the OLE Controls check box and the Outline control check box. Then click OK.
  2. If the Outline control is not available, run Visual FoxPro setup again. Select the Professional Features option, select the OLE Controls check box, complete setup, and then repeat steps 1.a. and 1.b.
  3. On UserMachine, ensure that the Outline control is not installed and that Visual FoxPro 3.0 (standard or professional) is installed.

Distributing a Form that Contains an Outline Control

  1. Create a new form on DevMachine:

    1. On the File Menu, click New. Then click Form, and click the New button.
    2. Select the View Classes shortcut button in the Form Controls Toolbar.
    3. Select the Outline control, and create a new control on the form.
    4. Save this form as a class named Outltest in a Visual Class Library named Outltest.vcx. Then close and save this form as Outltest.scx.
  2. Run the form on UserMachine:

    1. Copy Outltest.scx, Outltest.sct, Outltest.vcx, Outltest.vct, and Msoutl32.ocx to UserMachine.

      NOTE: Msoutl32.ocx is located in the \Windows\System directory or, in Windows NT, it is located in the \Windows\System32 directory.
    2. On the Program menu, click Do. Select the form, and click DO. As a result, you will see that the form runs and the control is functional.
    3. To test the outline, enter the following in the Command window:
            OUTLTEST.Olecontrol1.Additem('First Item')										
  3. On the File menu, click Open, and set the type of file to Visual Class Library. Then select Outltest.vcx.
  4. Click OK to the following error message:
    OLE error code 0x80040112: Appropriate license for this class not found. OLE object is being ignored. Record Number 4.
  5. When the form opens, verify that the Outline control is no longer there.
  6. Make a change to the form, and close it. Click Yes when prompted to save.
  7. Open the Outltest class from Outltest.vcx again, and verify that the form that comprises the class was saved without the Outline control.

Distributing a Visual Class that Contains an Outline Control

  1. Create the visual class on DevMachine:

    1. On the File menu, click New, and then click Class to create a new class. Name the new class RedOutl.vcx. Base it on OLEContainerControl and save it in a Visual Class Library called Olelib.vcx.
    2. Select the OLE container control from the formtool tool bar. When the Insert Object dialog box appears, select OLEControl. Then select the Outline control.
    3. Double-click the BackColor property, and select red from the dialog box.
    4. Close and save this class.
    5. Create a new form.
    6. Click the View Classes shortcut button. Then click Add, and select the Visual Class Library Olelib.vcx.
    7. Select RedOutl, and create a new control on the form.
    8. Close and save the form as Subtest.scx
  2. Run the form on UserMachine

    1. Copy Olelib.vcx, Olelib.vct, Subtest.scx, Subtest.sct, And Msoutl32.ocx.
    2. On the Program menu, click Do, and select Subtest.scx. As a result, you will see that the form runs without error, and the Outline control is functional.
  3. Create a new form and add Olelib.vcx to the Form Controls toolbar.
  4. Create a new control based on RedOutl. The following error occurs:
    Error: OLE Error Code 0x80040112: Appropriate license for this class not found.
NOTE: The visual class library OLELIB.VCX is used in the last example, sodo not delete this file.

Distributing a Program that Attempts to Create a New OLE Control

  1. Create a new program on DevMachine. Add the following code, and save it as Outltest.prg.
       PUBLIC NewForm   NewForm = CREATE("form")   NewForm.Show   NewForm.AddObject("NewOutline","OLEControl","MSOutl.Outline")   NewForm.NewOutline.visible=.t.								
  2. Run the program on UserMachine:

    1. Copy Outltest.prg and Msoutl32.ocx to UserMachine
    2. On the Program menu, click DO, select Outltest.prg, anc click DO. As a result, you will see that the form is created and shown and then the following error occurs:
      OLE Error Code 0x80040112: Appropriate license for this class not found.

Distributing a Program that Creates a New OLE Control from a Class

NOTE: This example requires the Visual Class Library Olelib.vcx filecreated in step 1 of the "Distributing a Visual Class that Contains anOutline Control" example.

  1. Create a new program on DevMachine, add the following code, and save the program as Subtest.prg:
       PUBLIC NewForm   NewForm = CREATE("form")   NewForm.Show   NewForm.ScaleMode = 3   SET CLASSLIB to OLELIB.VCX   NewForm.AddObject("NewOutline","RedOutl")   NewForm.NewOutline.RedOutl.visible=.t.								
  2. Run the program on UserMachine

    1. Copy the Subtest.prg, Olelib.vcx, Olelib.vct, and Msoutl32.ocx to UserMachine.
    2. Run the program. As a result, the form runs successfully.
license design user
Properties

Article ID: 139154 - Last Review: 12/04/2015 12:18:24 - Revision: 2.1

Microsoft Visual FoxPro 3.0 Standard Edition, Microsoft Visual FoxPro 5.0 Standard Edition, Microsoft Visual FoxPro 6.0 Professional Edition

  • kbnosurvey kbarchive kbautomation kbcode kbinfo kbinterop KB139154
Feedback