Once you have created an ActiveX control project containing one or more UserControl objects, you can compile it into an .ocx file and use the controls in other applications. The following procedures demonstrate this.
Note This topic is part of a series that walks you through creating a sample ActiveX control. It begins with the topic Creating an ActiveX Control.
Compiling the ControlDemo project
Visual Basic displays a warning message, because the TestCtlDemo project contains a reference to ControlDemo. Click Yes to remove ControlDemo anyway.
When you remove ControlDemo from the project group, Visual Basic looks for ControlDemo.ocx in the Windows Registry. If the .ocx file exists, Visual Basic automatically updates the reference you set in the procedure "Adding the TestCtlDemo Project."
To switch back to using the project instead of the binary component, you can click Add Project, on the File menu, and add the ControlDemo project back to the project group.
When ControlDemo is running from source code, you cannot access the ShapeLabel control from other applications, or from another copy of Visual Basic. This is because ActiveX control components must run in process. Once you have compiled a .ocx component, you can test it from other applications.
To use ControlDemo.ocx in another copy of Visual Basic
The icon for ShapeLabel appears on the Toolbox. You can now add ShapeLabel controls to the default form, and use the Properties window to set their properties. You can also right-click on an instance of ShapeLabel, and choose Properties from the Context menu to edit the control’s properties with the property page.
You can also compile the project and run the .exe.
For More Information An .ocx file can contain multiple controls and property pages. "Distributing Controls," in "Building ActiveX Controls," discusses control packaging and distribution.
This topic is part of a series that walks you through creating a sample ActiveX control.
To | See |
Go to the next step | Control Creation Recap |
Start from the beginning | Creating an ActiveX Control |