Visual Basic Concepts

Adding an AboutBox to Your Control

See Also

ActiveX controls typically have an About "property" at the top of the Properties window, with an ellipsis button. Clicking the button shows an About box identifying the control and the software vendor that created it.

Visual Basic makes it easy to provide such About boxes. You can have separate About boxes for each control in your control component (.ocx file), or one About box that all the controls in the component share.

To add an About box to a control component

  1. Create an About box by adding a form to your ActiveX control project, and giving it appropriate text and controls. Name the form dlgAbout.

  2. In the code window for any control in the project, add the following Sub procedure:
    Public Sub ShowAboutBox()
        dlgAbout.Show vbModal
        Unload dlgAbout
        Set dlgAbout = Nothing
    End Sub
    

    Important   Unloading the About box and setting it to Nothing frees the memory it was using. This is a courtesy to the user of your controls.

  3. On the Tools menu, click Procedure Attributes to open the Procedure Attributes dialog box. If the ShowAboutBox procedure is not selected in the Name box, click the drop down and select it.

  4. Click Advanced to expand the Procedure Attributes dialog box.

  5. In the Procedure ID box, select AboutBox to give the ShowAboutBox procedure the correct identifier.

  6. Repeat steps 2 through 5 for each control in the project.

Note   The name of the About box form and the method that shows it can be anything you like. The procedure above used dlgAbout and ShowAboutBox for purposes of illustration only.

If you wish to have separate About boxes for each control, simply create additional forms, and show a different form in each control's ShowAboutBox method.

Of course, each form you add to the project increases its size. You can get the same effect with the single dlgAbout form by giving it a property named, let us say, ControlID. This property identifies which control dlgAbout is being shown for. In each control's ShowAboutBox method, set the ControlID property before showing dlgAbout. Place code in the Load event of dlgAbout to change the text and bitmaps on the About box appropriately.

For More Information   Adding properties and methods to forms is discussed in "Programming with Objects," in the Visual Basic Programmer's Guide.