Adding New Menu Items

To add menu items to all the topics in your title, you enter the AppendItem command in the [CONFIG] section of the project file. The AppendItem command has the following syntax:

AppendItem("menu-id", "item-id", "item-name", "command")

Menu-id is the menu ID, enclosed in quotes, you specified in the InsertMenu command that created the menu. This ID tells Viewer which menu you're putting the new command on. For a standard Viewer menu, this ID is one of the following predefined menu IDs:

Menu ID Menu

mnu_file File
mnu_edit Edit
mnu_bookmark Bookmark
mnu_help Help

Item-id is a name, enclosed in quotes, that Viewer uses internally to identify your menu item. To remove or disable the item, or change the operations that the item performs, in certain topics, you use this name to identify the menu item.

Item-name is the name, enclosed in quotes, Viewer displays on the menu for the item.

Command is the Viewer command you are executing, enclosed in double quotes. The command can also be a function in an external DLL that you've registered as a Viewer command using Viewer's RegisterRoutine command. The HAudioCommand, HAudioDialog, HDisplayBmp, and HAnimateCommand commands are examples of external DLL calls registered as Viewer commands. (See Chapter 18, “Multimedia Viewer Commands,” for more information on how to use RegisterRoutine.)

The following example adds an item labeled “Time” to the Utilities menu (created in the previous section). It uses the ExecProgram command to run the Windows Clock application.

[CONFIG]
AppendItem("menu_util", "time_item", "&Time", "ExecProgram(`alarmclk', 0)")

The menu item appears on the Utilities menu as follows:

Note:

The AppendItem command is also used to add commands to Viewer's Help menu. See Chapter 13, “Creating Help for a Title,” for details.