Megosztás a következőn keresztül:


Visual Basic Concepts

Negotiating Menu and Toolbar Appearance

When an object supplied by another application is activated on a form, there are a number of ways that object's menus and toolbars may appear on the container form; therefore, you need to specify how they will be displayed. This process is called user-interface negotiation because Visual Basic and the object you have linked or embedded must negotiate for space in the container form.

Controlling Menu Appearance

You can determine whether a linked or embedded object's menu will appear in the container form by setting a form's NegotiateMenus property. If the child form's NegotiateMenus property is set to True (default) and the container has a menu bar defined, the object's menus are placed on the container's menu bar when the object is activated. If the container has no menu bar, or the NegotiateMenus property is set to False, the object's menus will not appear when it is activated.

Note   The NegotiateMenus property does not apply to MDI Forms.

Controlling Toolbar Appearance

The MDI form's NegotiateToolbars property determines whether the linked or embedded object's toolbars will be floating palettes or placed on the parent form. This behavior does not require toolbars to be present on the MDI parent form. If the MDI form's NegotiateToolbars property is True, the object's toolbar appears on the MDI parent form. If NegotiateToolbars is False, the object's toolbar will be a floating palette.

Note   The NegotiateToolbars property applies only to MDI forms.

If an MDI form includes a toolbar, it is usually contained in a picture box control on the parent form. The picture box's Negotiate property determines whether the container's toolbar is still displayed or is replaced by the object's toolbar when activated. If Negotiate is True, the object's toolbar is displayed in addition to the container's toolbar. If Negotiate is False, the object's toolbar replaces the container's toolbar.

Note   Menu and toolbar negotiation will occur only for insertable objects that support in-place activation. For more information on in-place activation, see "Programming with ActiveX Components."

You can see how these three properties interact by using the following procedure.

To perform menu and toolbar negotiation

  1. Add a toolbar to an MDI form. This is described in "Creating a Toolbar" earlier in this chapter.

  2. Place an insertable object on a child form.

  3. Set the NegotiateMenus, NegotiateToolbars, and Negotiate properties.

  4. Run the application, and double-click the object.