Visual Basic Concepts
Adding a Menu to the ActXDoc Project
You can add menus to your ActiveX document using the Menu Editor. Because an ActiveX document alone cannot have a menu, the menu you create will be merged with the application you used to view the ActiveX document. Thus, you must consider menu negotiation when adding a menu to an ActiveX document.
When users navigate to your ActiveX document, they may not have any indication of its origin (or that it is an ActiveX document). To remedy this, you should always include an "About" form with your ActiveX document.
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 menu and About box to the FirstDoc ActiveX document
On the Project menu, click Add Form.
In the Add Form dialog box, double-click the About Dialog icon to add an About Box form to the project.
Set Caption property of the form and controls according to the following table.
Object | Caption value |
frmAbout | About FirstDoc |
lblTitle | FirstDoc ActiveX Document |
lblVersion | Version 1.0 |
lblDescription | ActiveX document |
Delete the Label control named lblDisclaimer.
In the Project Explorer window, double-click FirstDoc to bring its designer forward.
Click the FirstDoc designer to select it, and on the Tools menu, click Menu Editor to display the menu editor dialog box.
Click the Caption box and type &Help.
Click the Name box and type mnuHelp.
Click the NegotiatePosition box, and click Right.
Click the Next button to create a new menu item.
In the Caption box type About FirstDoc.
In the Name box type mnuAbout.
Click the right-facing arrow button to indent the menu item.
Click OK.
Double-click the FirstDoc designer to bring its Code window to the front.
Add the following code to the mnuAbout Click event:
Private Sub mnuAbout_Click() frmAbout.Show vbModal End Sub
Running the Project
Once you have added a menu to the UserDocument, you can run the project, view the ActiveX document in Internet Explorer, and see the how the menu has been negotiated.
Run the project by pressing F5.
In Internet Explorer, type the path of the FirstDoc.vbd file in the Address box or select it from the drop-down list of previously typed addresses.
On Internet Explorer's command bar, click the Help menu, and among the menu items will be the FirstDoc Help menu item.
Click About FirstDoc to see the new About box.
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 | Life Cycle of a UserDocument |
Start from the beginning | Creating an ActiveX Document |