GWMenuItems

Enumerates the items on a menu. The menu items collection maintains references to the commands placed on the menu (GWMenuItems::Add). When the corresponding GWMenu is destroyed, the GWCommand objects placed on the menu are released.

Properties

The following table lists the properties for this class, along with access and descriptions.

Property

Access

Description

Count

R/O

Long.

Parent

R/O

GWMenu.

_NewEnum

R/O

Enumeration object Implements IEnumVARIANT. Fo´r Windows only.

Methods

GWMenuAction Add( String caption, GWCommand item [,Variant AddBefore] )
  • The AddBefore parameter refers to either a string (display name) of a menu item or to an index (ordinal).
GWMenu AddMenu( String caption [, GWCommand item ] [, Variant AddBefore] )
  • The AddBefore parameter refers to either a string (display name) of a menu item or to an index (ordinal).
  • The item parameter is optional, but it is useful for long prompt functions for the submenu.
GWMenuSeparator AddSeparator( [ Variant AddBefore] )
  • The AddBefore parameter refers to either a string (display name) of a menu item or to an index (ordinal).
GWMenuItem Item( Variant item )
  • The item parameter refers to either a string (display name) of a menu item or to an index (ordinal).
GWMenuItem FindByHMenu( Long hMenu )
  • Returns the GWMenu object that contains a Command property with the menu handle.
  • This method returns NULL when AddMenu is called without providing a GWCommand object. In this case, the client (caller of this method) should assume that the menu is enabled and has no long prompt.
  • This method is recursive. If the hmenu is contained in a menu that is inside the MenuItems collection, FindByHMenu locates it.
GWMenuItem FindByID( Variant ID )
  • Returns the GWMenuItem object that corresponds to the menu identifier. The ID parameter refers to the actual Menu ID, not to a PersistentID. Separators cannot be found within this method.
  • The ID parameter refers to the number (actual menu ID).
  • This method is recursive. If the ID is contained in a menu that is inside the MenuItems collection, FindByIDl locates it.

Remarks

C3PO software generally adds items to (or remove them from) the menu while calling the CommandFactory methods, such as CustomizeMenu. In this case the C3PO does not redraw the menu bar. However, if the C3PO maintains a reference to GWMenuItems and adds (or removes) items at another time, there is no guarantee that the menu bar will be redrawn properly.

The Item and AddBefore parameters do not allow you to specify a persistent ID. The workaround is to call FindByID method to obtain GWMenuItem, then pass the menu ID or display string available from that object into the Item method or as the AddBefore parameter.