Click or drag to resize

Menu Class (Typed)

X#
Create a menu. Menus consist of items which the user selects for execution; a menu item can be a string, a bitmap, or another menu.
Inheritance Hierarchy
Object
  VObject
    Menu

Namespace:  XSharp.VO.SDK
Assembly:  XSharp.VOGUIClasses (in XSharp.VOGUIClasses.dll) Version: 2.19
Syntax
 CLASS Menu INHERIT VObject
Request Example View Source

The Menu type exposes the following members.

Constructors
  NameDescription
Public methodMenu
Construct a menu.
Top
Properties
  NameDescription
Public propertyAccelerator
The accelerator table to be used with this menu.
Public propertyToolBar
The toolbar that corresponds to the menu.
Top
Functions
  NameDescription
Public methodAppendItem
Add a string to the end of this menu.
Public methodCheckItem
Place a check mark to the left of a specified menu item.
Public methodDeleteItem
Delete an item from this menu, removing it from memory. (To delete a bitmap or string, specify an ID; to delete a submenu, specify the Menu object.)
Public methodDestroy
Provide a method to de-instantiate a Menu object.
(Overrides Destroy.)
Public methodDisableItem
Disable a specified menu item (until a subsequent call to Menu:EnableItem()).
Public methodEnableItem
Enable a specified menu item that was previously disabled.
Public methodGetMenuID
Public methodHandle
Return the handle for a menu.
Public methodHyperLabel
Return the hyperlabel attached to the menu item, or NIL if it has none.
Public methodInsertItem
Insert a new menu item before a specified menu item.
Public methodMakeMenuRtol
Reverse the order of the menu items in a menu. This is only necessary if you are using an International, bi-directional version of Windows.
Public methodName
Return the name, as a string, stored in the hyperlabel attached to the menu command, or NIL if there is none.
Public methodPostInit
Implement customized initialization code for the window.
Public methodPreInit
Implement customized initialization code for the server.
Public methodRegisterItem
Register the hyperlabel for this menu item.
Public methodSetAble
Public methodSetAutoUpdate
Append a section to a specified submenu on a menu. This section automatically keeps track of what MDI child windows are currently open and displays their names on the submenu.
Public methodSetCheck
Public methodSetShortCuts
Public methodShowAsPopup
Display menu as a local pop-up menu.
Public methodUncheckItem
Remove the check mark (that the user sees) from the menu item. Typically, you do this in response to a MenuCommandEvent on that item.
Public methodUnregisterItem
Unregister the hyperlabel for this menu item.
Top
Globals and Defines
  NameDescription
Public fieldoCargo
Cargo slot.
(Inherited from VObject.)
Top
Remarks
Menus provide the highest level of user control within an application. At the most basic level, a menu is series of items that are displayed in the menu bar (for example, the strings "OpenFile", a question mark bitmap to indicate help, and so on.) When selected, these items perform an action—for example, open a file, exit the application, or get help. The items in a menu bar might also contain a submenu as another type of item. When creating a submenu, you generally specify a title (this is the text that appears in the menu bar) and the set of items that belong to that submenu (the items are displayed when the title is activated in the menu bar). For example, a submenu might have the title "File" and items named "Open," "Save," and "Exit." Like menus, submenus can contain strings, bitmaps, and other menus. Using submenus allows you to have multi-dimensional menus. In addition, just like any menu, they can be created from a resource entity. Each item on a menu is identified by a unique ID. You can then use that ID to refer to the item later in your program (for example, to disable or delete an item). Menu commands can be selected with the mouse or with an accelerator key, and can be added, deleted, inserted, and appended as required. Items on a menu can be dimmed (or grayed) to indicate that they are disabled, and they can be checked to indicate that they are enabled/selected. You can also add separators to a menu. (A separator is a single line inserted between items on a submenu to group similar commands together.) A menu is usually associated with an accelerator table that defines shortcuts (like Ctrl+S for File Save) and a toolbar that provides certain buttons issuing commonly used menu commands. The toolbar and accelerators are usually carried by the menu; assigning a menu to a window automatically assigns the toolbar and accelerators as well. Menus in X# generate the following events—MenuInitEvent, MenuSelectEvent, and MenuCommandEvent. They are dispatched to the window that owns the menu that generated the event. The event handler methods for these events are as follows: Window:MenuInit() is called before a menu is displayed. Window:MenuSelect() is called when a menu command is highlighted. When the user selects a menu command for execution, the window method that matches the menu command's name is called, if any. If there is no matching method, Window:MenuCommand() is called. Menu commands are also propagated up the window ownership hierarchy. For an in depth discussion of how command events are used, refer to the Programmer's Guide. In the Windows, menus are normally created in resource entities. (You can also construct menus dynamically using the Append... or Insert... methods of Menu.) For example, in Windows, menus can be created in a resource entity as follows:
X#
 1RESOURCE IDM_DEMO MENU
 2BEGIN
 3POPUP "&File"
 4BEGIN
 5MENUITEM "&New",            IDMI_NEW
 6MENUITEM "&Open...",        IDMI_OPEN
 7MENUITEM "&Save",            IDMI_SAVE
 8MENUITEM "Save &As...",        IDMI_SAVEAS
 9MENUITEM SEPARATOR
10MENUITEM "E&xit",            IDMI_EXIT
11MENUITEM "A&bout Demo...",    IDMI_ABOUT
12END
13END
The easiest way to construct a menu is by using the Menu Editor. It generates the resource, as illustrated in the example above, as well as the subclass used to instantiate the menu, the accelerator table, and the toolbar.
See Also