Skip to main content

Merging Bars and Menus in MDI Applications

  • 2 minutes to read

This document describes how the ExpressBars Suite allows you to combine bars and menus in MDI applications.

Bar Merge Mechanism

In MDI applications, toolbars and menus of the parent and child forms are displayed (by default) within their corresponding windows. Normally, the menu of the parent form provides general commands (for working with files, windows, etc.), while a child form has toolbars and menus that provide the functionality specific to this child form. To preserve toolbar/menu navigation capabilities, the bar merge mechanism is used. This mechanism allows you to:

  • Merge these bars and menus when a child form is activated or maximized. Use a bar manager’s AlwaysMerge option to control when bar merging occurs.

  • Restore the original bars and menus when the form’s state is reverted back.

Customizing Bar Merge Logic

By default, the ExpressBars Suite automatically merges main menus and adds toolbars from a child form to the parent form. To customize the default merge mechanism, handle a bar manager’s OnMenuMerge and OnMerge events. In the event handler, you can:

In addition, you can handle the OnBeforeMerge and OnAfterMerge events to update form elements in response to the logic you provided with the OnMenuMerge and OnMerge event handlers.

By default, the merge operation adds bar item links from one toolbar/menu to another. You can customize the default merge behavior for each bar item link via the following options:

  • Bar item’s MergeKind property. With this property, you can:

  • combine contents of sub items or container items provided that their item link captions match (mkMergeByCaption);

  • prohibit the bar item’s links from being added to or combined with other bar item links (mkNone);

  • accept the default behavior for the bar item’s links (mkAdd).

  • Bar item’s MergeOrder property. Use this property to specify the visual position when the item’s link is added to a toolbar or menu.

  • Bar manager’s OnMergeItemLink event. Handle this event during merge operations to dynamically specify both merge behavior and position for each bar item link via the AMergeKind and AMergeIndex event parameters.

See Also