Using the Custom Control in Other Projects

By adding the test project to the custom control project we were able to design and test the control in the same environment. A great help indeed but the custom control can’t be used in other projects. If you start another instance of Visual Basic and attempt to add your custom control to the toolbox you won’t see the FLEX Label entry in the Components dialog box. Other projects see only components that” were registered with the system .

To register your custom control you must create the corresponding OCX file. Choose Pile > Make Flx Label ocx. The OCX file is all your need to include the control in your projects. OCX files can be placed anywhere on your disk but they are-usually stored in the Windows\System folder. You can create the OCX file in the same folder as the project. ‘While Visual Basic creates the OCX file it also registers it in the system Registry so you shouldn’t move the OCX file to another’ location later. To use a custom control with a new project follow these steps:

1. Start a new Standard EXE project and add the new control to the toolbox.
2. Right-click the toolbox and from the shortcut menu select Components to display the Components dialog box:

3. Check the FLEX LABEL check box and click OK. The custom control’s icon will appear on the project’s toolbox. Notice that the name of the control is the same as the project’s name.

If you use this icon to place a FLEXLabel control on a Form Visual Basic automatically names it Label3Dl (if it’s the first control on the Form; the second will be named Label3D2, and so on)

The custom control has been registered with the system Registry on your computer but how about other computers? When you distribute an application that uses the custom control the new control must be installed on the host computer before your application can use it. To install a custom control to another system use the Regsvr32 utility passing the name of the OCX file as an argument. Assuming you have copied the FLX LABEL OCX file to the Windows System folder use the following command from the DOS prompt to install it on the host system:

REGSVR32 FLXLABEL.OCX

If the OCX file resides in another folder switch to its folder and issue this command:

C:\WINDOWS\SYSTEM\REGSVR32 FLXLABEL.OCX

To uninstall a custom control use the REGSVR32 program with the IU option The following command will uninstall the FLX LABEL control:

c.\WINDOWS\SYSTEM\REGSVR32 FLXLABEL.·OCX /U

Scroll to Top