Visual Basic Concepts
Adding Forms and Modules to ActiveX Document Projects
When you create a Visual Basic project, you are used to starting with a standard Form. When you create an ActiveX document, you are by no means limited to using only ActiveX documents: You can add standard forms and modules to your project, as you would to any other project.
Modeless Dialog Boxes Sometimes Aren't Allowed
When you create an ActiveX DLL, you'll have one limitation: Depending on the container, modeless dialog boxes may or may not be displayed. For example, imagine that you've created an ActiveX DLL that includes an ActiveX document that shows a modeless form. If you view the document in Office Binder, showing the modeless form will present no problems. On the other hand, if you view the same document in Internet Explorer, attempting to display the same modeless form will raise an error.
Note With Internet Explorer 4.0 or later, the ability to show modeless forms is dependent on the threading model. This is discussed in "Apartment-Model Threading in Visual Basic" in "Building Code Components."
Avoid the Problem Using the NonModalAllowed Property
However, the problem of not being allowed to display a modeless dialog box can be side-stepped. Using the NonModalAllowed property, you can check before displaying a form, and react appropriately. In short, the NonModalAllowed property (a read-only property), returns True or False, depending on whether or not the App object allows modeless forms to be displayed. Simple code can then be written as in the following example:
Private Sub cmdShowMe_Click()
If App.NonModalAllowed Then ' Show the form
' modeless.
frmModeless.Show vbModeless, Me
Else ' Show the form modally.
FrmModeless.Show vbModal, Me
EndIf
End Sub
For More Information For more details about displaying forms, see "Displaying Forms from Code Components" in "General Principles of Component Design."