Resources | Resources |



Menu model

IMenuModel is derived from the IListModel interface and is used to model a collection of objects, each of which is considered to be an item in a menu.

The menu model is typically used to manage the storage of data for a user interface object that takes the appearance of a menu -- such as a popup menu form. The menu model stores menu item data from which a menu can be built, maintaining that data in the order that it would appear in a menu on the display.

In general (though it depends on the object that is attached to the menu model), the items in the menu model are displayed top-to-bottom from items 0 through item (n - 1), with item zero being at the top of the menu and item (n - 1) at the bottom.

The menu model interface provides functions for:

  • managing the reference count of the interface
  • accessing or modifying the data
  • allowing widgets and UI controls to register for a listener with the menu model

Using menu model

The example shown below creates a simple menu that contains only one layer. It is possible to use flags such as MMF_SUBMENU to create hierarchical trees of menus.

int result;
IMenuModel *piMenuModel = NULL;
result = ISHELL_CreateInstance(piShell, AEECLSID_CMenuModel, 
          (void **)&piMenuModel);
// Perform actions such as adding listeners
if (result == AEE_SUCCESS) {
  for(i=0; i