Share via


Visual Basic Concepts

Adding a Form to the ActXDoc Project

As with other Visual Basic projects, it's a simple matter to add a form to the FirstDoc ActiveX project. Adding controls to the form is exactly the same as in a standard Visual Basic project. The primary difference, of course, lies in the fact that forms must be called by the ActiveX document.

In this step-by-step procedure, you add a single form to the ActXDoc project.

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 Document.

To add a form to the ActXDoc project

  1. On the Project menu, click Add Form, then double-click the Form icon in the Add Form dialog box. Set the form's properties using the following table:
Form1 property Value
Name frmAux
Caption Auxiliary Form
  1. On the Toolbox, double-click the TextBox icon to add a TextBox control to the form, and set its properties using the following table.
Text1 property Value
Name txtAux
MultiLine True
Text (nothing)
  1. Resize the form, and place the control on the form so it resembles the following figure:

  2. In the Project Explorer window, double-click the FirstDoc icon to bring its designer forward.

  3. On the Toolbox, click the CommandButton icon and draw a new button on the FirstDoc designer, and set its properties according to the following table:

Command1 property Value
Name cmdShowForm
Caption Show Form
  1. Place the control just below the Go Next button as shown:

  2. Double-click the Show Form CommandButton control, and add the following code to its Click event:

    Private Sub cmdShowForm_Click()
       ' Show the auxiliary form, and set the Text
       ' property of txtAux to the URL of FirstDoc.
       frmAux.txtAux.Text = txtURL.Text
       frmAux.Show vbModal
    End Sub
    

    Important   Some containers, such as Internet Explorer, don't support the showing of modeless forms called from within a DLL. If you want to show modeless forms, compile your ActiveX document as an .exe file. This will allow your applications to show both modeless and modal forms.

  3. On the File menu, click Save Project to save the project files. Visual Basic will prompt you to name the form as its default (frmAux). Click OK to save the form with the default name.

Running the Project

You can now run the project and observe the interaction of the form with the ActiveX document.

To view the new form interacting with the ActiveX document

  1. Press F5 to run the project.

  2. Click the Address box and type the path of the FirstDoc.vbd.

  3. Click the Show Form button to see the form.

Step by Step

This topic is part of a series that walks you through creating a sample ActiveX document.

To See
Go to the next step Adding a Property to the UserDocument
Start from the beginning Creating an ActiveX Document