Menu items are displayed on menus, which appear when the user selects a menu name on the menu bar. Menu items are associated with Help macros, so when the user chooses a menu item, the Help macro is run.
Help provides two macros for adding menu items, AppendItem and InsertItem. As their names imply, the first macro adds a menu item to the end of a menu, and the second macro inserts a menu item at a specific place on the menu.
To add a menu item in a specific position, you use the InsertItem macro, which has the following syntax:
InsertItem("menu_id", "item_id", "item_text", "item_macro", item_position)
For example, the following macro adds a Show Index Window menu item as the first item on an Options menu:
InsertItem("mnu_options","item_showindex","Show &Index Window...", "JI(`index.hlp', `idx_main')", 0)
By placing an ampersand (&) before the word Index of the menu item text, the macro assigns the mnemonic character I to the menu item. Also notice the use of the ellipses following the menu item text; this is a Windows convention that indicates the menu item displays a dialog box.
In the next example, a more complex macro is added to an Options menu:
InsertItem("mnu_options","item_showindex","Show &Index Window",
"IfThenElse(IsMark(`show_index'),
`DeleteMark(`show_index')',
`SaveMark(`show_index')')",0)
When the user chooses the resulting menu item, the macro saves or deletes a marker, depending on whether the marker is already set in the Help file.
Note:
You cannot insert menu items between or after the standard items on the Bookmark menu (with the menu ID “mnu_bookmark”). Help appends the standard items to any custom ones you’ve inserted.
The AppendItem macro uses the same parameters as the InsertItem macro, but it omits the position parameter. Menu items created using AppendItem are added to the end of the specified menu. The AppendItem macro can be easier to use in the Help project file because, rather than having to specify position values, you can just arrange the macros in the [CONFIG] section in the order you want the menu items to appear. To change the order of the menu items, you just change the order of the macros.
To remove a menu item, use the following macro:
DeleteItem("item_id")
For example, to remove the Show Index Window menu item from the previous example, you use the following macro:
DeleteItem("item_showindex")