Home>>Programming>> » How to Use Menu Templates and Save a Menu as a Template

How to Use Menu Templates and Save a Menu as a Template

Last Updated on August 2, 2018 By hcyaobin

How to use menu templates?

C++Builder or Delphi provides several predesigned menus, or menu templates, that contain frequently used commands. You can use these menus in your applications without modifying them (except to write code), or you can use them as a starting point, customizing them as you would a menu you originally designed yourself. Menu templates do not contain any event handler code.

The menu templates shipped with C++Builder are stored in the BIN subdirectory in a default installation. These files have a .dmt (C++Builder or Delphi menu template) extension.

You can also save as a template any menu that you design using the Menu Designer. After saving a menu as a template, you can use it as you would any predesigned menu. If you decide you no longer want a particular menu template, you can delete it from the list.
To add a menu template to your application,

  1. 1 Right-click the Menu Designer and choose Insert From Template.
    (If there are no templates, the Insert From Template option appears dimmed in the context menu.)
    The Insert Template dialog box opens, displaying a list of available menu templates.
    Select the menu template you want to insert, then press Enter or choose OK.
    This inserts the menu into your form at the cursor’s location. For example, if your cursor is on a menu item in a list, the menu template is inserted above the selected item. If your cursor is on the menu bar, the menu template is inserted to the left of the cursor.

To delete a menu template,

  1. Right-click the Menu Designer and choose Delete Templates.
    (If there are no templates, the Delete Templates option appears dimmed in the context menu.)
    The Delete Templates dialog box opens, displaying a list of available templates.
  2. Select the menu template you want to delete, and press Del.
    C++Builder deletes the template from the templates list and from your hard disk.

How to save a menu as a template?

Any menu you design can be saved as a template so you can use it again. You can use menu templates to provide a consistent look to your applications, or use them as a starting point which you then further customize.

The menu templates you save are stored in your BIN subdirectory as .dmt files.
To save a menu as a template,

  1. Design the menu you want to be able to reuse.
    This menu can contain as many items, commands, and submenus as you like; everything in the active Menu Designer window will be saved as one reusable menu.
  2. Right-click in the Menu Designer and choose Save As Template.
    The Save Template dialog box appears.
    In the Template Description edit box, type a brief description for this menu, and then choose OK.
    The Save Template dialog box closes, saving your menu design and returning you to the Menu Designer window.

Note: The description you enter is displayed only in the Save Template, Insert Template, and Delete Templates dialog boxes. It is not related to the Name or Caption property for the menu.

Add a Comment

Your email address will not be published. Required fields are marked *