Share via


Visual Basic Concepts

Controls You Can Use As Constituent Controls

You can place any of the controls supplied with Visual Basic on a UserControl, with the exception of the OLE container control.

Any ActiveX control you've purchased, or any control written to the older OLE specification, can be placed on a UserControl.

As long as you're authoring a control for your own use, that's all you need to know. However, if you're going to distribute your control to others, even if you're giving it away, you need to consider distribution and licensing issues.

Note   Toolbox objects other than controls, such as insertable objects — for example, Microsoft Excel Charts — cannot be placed on UserControl objects.

The Easy Part — UserControl and Intrinsics

The UserControl object and the Visual Basic intrinsic controls are created by the Visual Basic run-time DLL. Anyone who installs your .ocx file will automatically get a copy of the run-time DLL and support files, so if you author your controls using just the UserControl and intrinsic controls, you have no further licensing or distribution issues to worry about.

The intrinsic controls include: PictureBox, Label, TextBox, Frame, CommandButton, CheckBox, OptionButton, ComboBox, ListBox, HScrollBar, VScrollBar, Timer, DriveListBox, DirListBox, FileListBox, Shape, Line, Image, and Data.

ActiveX controls included with the Professional Edition of Visual Basic are subject to licensing rules, as explained below.

Note   The Microsoft User Forms in Microsoft Office applications include a set of controls similar to the intrinsic controls. These controls may be used on a UserControl; however, you must distribute the support DLL for Microsoft User Forms in your Setup program.

Distributing Constituent Controls

An instance of your control is composed of a UserControl object and its constituent controls, as explained in "The UserControl Object," earlier in this chapter. In order to add an instance of your control to a form, a developer must be able to create these objects.

SetupWizard makes this task easy. When you create a Setup program for your .ocx file, SetupWizard includes all the .ocx files for the constituent controls, along with the Visual Basic run-time DLL and any necessary support files.

When a developer runs your Setup program, the .ocx files that provide the constituent controls are installed on his computer. The only other thing he needs to worry about is whether he has the legal right to use them.

If none of the constituent controls require a license, the developer is set. However, if you used controls you purchased, or any of the ActiveX controls included with Visual Basic, Professional Edition, there are licensing requirements to be met.

Licensing Constituent Controls

When you purchase a control, you generally acquire the right to distribute instances of that control royalty-free as part any application you create. However, such license agreements do not give you the right to sell or give away the control to other developers — which is what you're doing when you use it as a constituent control.

So the rule is: In order to use your control, a developer must have licenses for all the licensed controls you've used as constituent controls.

Most ActiveX Controls Included with Visual Basic Are Exempted

The licensing rule stated above applies to the DBGrid control. Any of the other ActiveX controls included with the Professional Edition of Visual Basic can be used as constituent controls of a control you intend to distribute to other developers.

For example, if you use the TreeView control as a constituent control, anyone who is licensed to use your control is licensed to use TreeView as part of your control. (If you didn't include licensing support when you made your .ocx, this means that anyone can use your control. See "Licensing Issues for Controls," later in this chapter.)

Important   Your license agreement for Visual Basic states that in order to distribute any redistributables included with Visual Basic, the software you author must add significant and primary functionality. This means that a control that uses TreeView as a constituent control must do significantly more than TreeView does by itself. Consult your Microsoft License Agreement for details.

For more information about how to use ActiveX controls included with the Professional and Enterprise Editions, see "Using ActiveX Controls."

Distribution and Licensing Examples

Applying the rule yields the following examples.

ActiveX Controls Included with Visual Basic

Suppose you author some controls using some of the ActiveX controls included with Visual Basic, Professional Edition. SetupWizard adds the necessary .ocx files to your Setup program.

As long as you didn't use the DBGrid control, anyone who runs SetupWizard can use your controls. That's not always the case if you used DBGrid as a constituent control, as these scenarios show:

  • A developer who has a copy of Visual Basic, Professional Edition buys your .ocx and installs it. She already has the supporting .ocx files for DBGrid, and the license for it, so she has everything she needs.

  • A student who has a copy of Visual Basic, Learning Edition buys your control and installs it. He now has the supporting .ocx file for DBGrid, but doesn't have the license to use it.

  • A stock market analyst who has a copy of Microsoft Excel buys your control and installs it. She now has the supporting .ocx files for DBGrid, but doesn't have the license to use it.

ActiveX Controls You've Purchased

Suppose you purchase MegaDino.ocx from Late Cretaceous Computing, and use the Tyrannosaur and Velociraptor controls from this .ocx to develop your own UltimatePredator control. You package this control in UPred.ocx, and you give it away.

Anyone to whom you give a copy of UPred.ocx must have purchased and installed MegaDino.ocx in order to use the UltimatePredator control legally. This is true regardless of the development software they're using.

In fact, if the creators of MegaDino.ocx and DinoRama.ocx used the standard registry key licensing scheme, people to whom you give UPred.ocx will be unable to use the UltimatePredator control unless they have MegaDino.ocx installed.

Shareware Controls

Suppose you author your control using a shareware control.

If you sell your control component (.ocx file), the purchaser must also pay the author of the shareware control the appropriate license fee.

If you distribute your control component as shareware, a person who wants to use it must pay the appropriate license fees to you and to the author of the shareware control you used.

Constituent Controls and the Internet

If you want people to be able to use your control on World Wide Web pages, remember that the rule for Web servers is exactly the same as the rule for developers. That is, in order to use your control, a Web server must have licenses for all the licensed controls you've used as constituent controls.

For More Information   Licensing issues, including how to add licensing support for the controls you author, how licensing support works, and the mechanism for using licensed controls with the World Wide Web are discussed in "Licensing Issues for Controls," later in this chapter.