ALP Overview of VarioMenu components

What is VarioMenu?

VarioMenu is a set of ActiveX components which can create and dynamically maintain Windows main and popup menus. The difference from the classic menu resources included statically in every Windows application is that these menus are created at run-time and VarioMenu components provide an easy way for changing and handling them. Since VarioMenu objects are automation compatible and are designed to be used from scripts run from ActiveScripting engines, the design and handling of the created menus is done by script. This gives you the opportunity to create very flexible and dynamic menus for your application needing only knowledge of some scripting language - JScript or VBScript for example. The script can also handle the events related to menus and take the appropriate actions.

How does it work?HowItWorks.gif (5116 bytes)

VarioMenu architecture has three sides - the Windows application that makes use of the menus, called a host; the VarioMenu components themself and the script that creates and handles the menus. Host application creates and exposes VarioMenu objects to the script. It also stands in touch with the menu components and attaches the created menu to its window or refreshes it when it is updated. The script is hosted by the application too. It is given the VarioMenu objects created uses them to access, modify and handle the menus. Script functions are called to initially create the menu or are attached as events to handle clicking a menu item.

The structure of a menuMenuStructure.gif (5506 bytes)

VarioMenu architecture represents a simple object model for accessing menus. It consists of three objects: one root object created and exposed by the host application called VarioMenuTree; VarioMenuItem object that models one menu item and can have several children and several parents. Depending on what Type is specified for the menu item, its children can form a popup menu, a drop-down menu or a radio group in a menu. Finally there is one VarioMenuAccel object, which is accessible for every menu item and configures accelerator keys for it, if this doesn't conflict with its type.

Every menu item has a collection of children and each child can also be a parent of other items. In that way a tree of menu items is formed. The host application can use some items from the tree for root elements in order to create main menu for its window or a popup menu.

Another feature is that one menu item can be placed at several locations in the tree - every location keeps a reference to that item. If the item has children, they go with it. So if you modify the state of this item or of its children, the change reflects all locations e.g. all menus where is is present. That means you can create Edit submenu in you main wondow's menu and then just place it once again in the appropriate place in the tree to use it for popup menu.

If we take the tree of menu items on the right for exmaple: Edit menu item is inserted (with all children) in PopupsRoot item under the name EditPopup. Note that in the nodes of the tree are showed only the names under which menu items are located in the collections. So EditPopup and Edit is one and the same object. The host application can create its main window menu from MainMenuRoot node and the generated menu will contain all child items under it. When needed, the application can track two popups, genrated from ItemPopup and EditPopup nodes of the tree. The script creates Edit | Cut, Copy, Paste items only the first time and sets their properties and event handlers. When it decides to create EditPopup, which contains the same items, it just inserts Edit menu item object in children's collection of PopupsRoot under the name EditPopup. From that point ahead, there is no difference if you change the state of Cut under EditPopup or under Edit - it will change on both places.

newObjects Copyright 2001-2006 newObjects [ ]