Menu Class (Typed) | ![X#](../icons/logo100.jpg) |
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
Namespace:
XSharp.VO.SDK
Assembly:
XSharp.VOGUIClasses (in XSharp.VOGUIClasses.dll) Version: 2.19
SyntaxThe Menu type exposes the following members.
Constructors
| Name | Description |
---|
![Public method Public method](../icons/pubmethod.gif) | Menu |
Construct a menu.
|
Top
Properties
| Name | Description |
---|
![Public property Public property](../icons/pubproperty.gif) | Accelerator |
The accelerator table to be used with this menu.
|
![Public property Public property](../icons/pubproperty.gif) | ToolBar |
The toolbar that corresponds to the menu.
|
Top
Functions
| Name | Description |
---|
![Public method Public method](../icons/pubmethod.gif) | AppendItem |
Add a string to the end of this menu.
|
![Public method Public method](../icons/pubmethod.gif) | CheckItem |
Place a check mark to the left of a specified menu item.
|
![Public method Public method](../icons/pubmethod.gif) | DeleteItem |
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 method Public method](../icons/pubmethod.gif) | Destroy |
Provide a method to de-instantiate a Menu object.
(Overrides Destroy.) |
![Public method Public method](../icons/pubmethod.gif) | DisableItem |
Disable a specified menu item (until a subsequent call to Menu:EnableItem()).
|
![Public method Public method](../icons/pubmethod.gif) | EnableItem |
Enable a specified menu item that was previously disabled.
|
![Public method Public method](../icons/pubmethod.gif) | GetMenuID | |
![Public method Public method](../icons/pubmethod.gif) | Handle |
Return the handle for a menu.
|
![Public method Public method](../icons/pubmethod.gif) | HyperLabel |
Return the hyperlabel attached to the menu item, or NIL if it has none.
|
![Public method Public method](../icons/pubmethod.gif) | InsertItem |
Insert a new menu item before a specified menu item.
|
![Public method Public method](../icons/pubmethod.gif) | MakeMenuRtol |
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 method Public method](../icons/pubmethod.gif) | Name |
Return the name, as a string, stored in the hyperlabel attached to the menu command, or NIL if there is none.
|
![Public method Public method](../icons/pubmethod.gif) | PostInit |
Implement customized initialization code for the window.
|
![Public method Public method](../icons/pubmethod.gif) | PreInit |
Implement customized initialization code for the server.
|
![Public method Public method](../icons/pubmethod.gif) | RegisterItem |
Register the hyperlabel for this menu item.
|
![Public method Public method](../icons/pubmethod.gif) | SetAble | |
![Public method Public method](../icons/pubmethod.gif) | SetAutoUpdate |
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 method Public method](../icons/pubmethod.gif) | SetCheck | |
![Public method Public method](../icons/pubmethod.gif) | SetShortCuts | |
![Public method Public method](../icons/pubmethod.gif) | ShowAsPopup |
Display menu as a local pop-up menu.
|
![Public method Public method](../icons/pubmethod.gif) | UncheckItem |
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 method Public method](../icons/pubmethod.gif) | UnregisterItem |
Unregister the hyperlabel for this menu item.
|
Top
Globals and Defines
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:
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