29.1 Overview

Menustrip class is the base class for MUI's object oriented menus. Its children are objects of Menu class, each of them describes exactly one menu.

A Menustrip object doesn't feature many options itself, but as a subclass of Family class, it simply acts as father for multiple Menu objects.

The Menustrip object is usually specified as a child of either Application class or window class with the attributes Application.Menustrip or Window.Menustrip. Additionally, it can also be used as a context menu for other MUI objects using the Area.ContextMenu attribute.

In an XML file a menu tree is defined using the <menustrip>, <menu> and <item> tags. Here is an example definition of a simple menustrip:

<menustrip id="mymenustrip">
    <menu title="Project">
        <item>Save as...</item>
    <menu title="Edit">
        <item shortcut="X">Cut</item>
        <item shortcut="C">Copy</item>
        <item shortcut="V">Paste</item>
    <menu title="?">
        <item>MUI settings...</item>
        <item>About MUI...</item>

Note the empty <item/> declarations: These will insert a separator bar to the menu tree. Using separator bars makes your menu more readable to the end-user. After you have written the XML declaration above you can add the menustrip to one of your windows by using the Window.Menustrip attribute as follows:

<window menustrip="mymenustrip">

It is also possible to add a menustrip as a context menu to one of your window's gadgets using the Area.ContextMenu attribute. The context menu will then appear whenever the user presses the right mouse button over the gadget that has a context menu. Here is an example of how to add a menustrip as a context menu to a listview:

<listview contextmenu="mymenustrip">

Please note that menustrips which are used as context menus must not contain more than one <menu> tree.

It is very important to note that you have to declare your menustrips in the <application> scope because menustrips are global objects and are only attached to windows or gadgets later on. That is why it is not allowed to declare menustrips inside a <window> XML scope.

Show TOC