Adding an About Box

All good programmers are proud of their work. So let's add an About box for our control. It's very easy, but goes a long way in providing the look and feel of a real production application.

Try It Out - Adding an About Box

1.  Simply add a new form to your dataCtl ActiveX control using Project-Add Form from the main VB menu. When the Add Form dialog is displayed, select the About Dialog form type:

2.  Selecting the About Dialog will automatically add this form to your project. When it is added, change the Title Bar's Icon property:

I simply selected a disk drive icon from those provided with VB. This is important because this is the icon that will show up when the user selects your file in the Project Explorer. While you are at it, use the same icon for the picture in the upper left-hand side of the about box by changing the Picture property of picIcon.

The Application Title and Version will automatically be added when the ActiveX control is compiled into a .OCX file. However, you must manually change the App Description and Warning labels on the form. This is a good opportunity to provide a description of your control. The form adds the code to bring up the System Info box if it is installed on the user's computer.

3.  The form is named frmAbout, so let's keep this descriptive name. We now must add a procedure to display the About box. Add a public sub routine to your control called showAbout. It's pretty straightforward. Here's the code to add:

Public Sub showAbout()
   frmAbout.Show vbModal
End Sub

When this sub is called, our new About form will be displayed modally.

4.  For us to get the About box to show up in our ActiveX control's property box, we must wire in the procedure. Simply select Tools-Procedure Attributes… from the main VB menu. In the Name drop-down box, select our new subroutine, showAbout. Add a brief description of our procedure here as well. This description will show up in the Object Browser. So when programmers look at our control with the Browser, they will see descriptions of the procedures.

5.  Click the Advanced>> button and select AboutBox as the Procedure ID for showAbout.

6.  When you are finished, press OK. This will wire our About box into the Properties box of our control. Then when the user selects About, the showAbout sub will be executed and our About box will be shown modally. Let's take a look at how this will look when our control is compiled into an .OCXfile.

Our previous step, that of wiring in the showAbout procedure, automatically added (About) to our control's Properties box. We now have both an (About) and (Custom) selection for our control. When the user selects (About), our new about form is displayed in all its glory:

While we're adding functions that help the user out, let's add an enhancement that center-stages our control on the user's tool palette.

© 1998 by Wrox Press. All rights reserved.