Description

Represents the main menu of a form.

Remarks

The MainMenu control represents the container for the menu structure of a form. A menu is composed of MenuItem objects that represent the individual menu commands in the menu structure. Each MenuItem can be a command for your application or a parent menu for other submenu items. To bind the MainMenu to the Form that will display it, assign the MainMenu to the Menu property of the Form.

The MainMenu object has been enhanced in the current release. It now supports the new Office 2000 look and feel. To take advantage of this new look, set the form's Menu property to a newly created instance of MainMenu, then set the Style property to Office 2000, for example:

$Form.Menu = $System.MainMenu() $Form.Menu.Style = 1

Menu icons are now supported. To use this new feature, set the MainMenu ImageList property to BuiltinImageList or use your own custom ImageList, then set the ImageIndex property of the MenuItem as required, for example:

$Form.Menu = $System.MainMenu() $Form.Menu.Style = 1 $Form.Menu.ImageList = $System.BuiltinImageList() $Form.FileMenu = $Form.Menu.MenuItems.Add("File") $Form.OpenMenu = $Form.FileMenu.MenuItems.Add("Open") $Form.OpenMenu.ImageIndex = 0

Example

The following function creates a MainMenu, assigns two MenuItem objects to the MainMenu and binds it to a form. This example assumes that you have passed a valid Form object to the function.

function CreateMyMainMenu($form) dim $mainMenu1, $menuItem1, $menuItem2 ; Create an empty MainMenu. $mainMenu1 = $System.MainMenu() ; Add two MenuItem objects to the MainMenu. $menuItem1 = $mainMenu1.MenuItems.Add() $menuItem1.Text = "File" $menuItem2 = $mainMenu1.MenuItems.Add() $menuItem2.Text = "Edit" ; Bind the MainMenu to Form1. $form.Menu = $mainMenu1; endfunction




The CHM file was converted to HTML by chm2web software.