InsertMenu Method (AMenu)

Version 6

 

Creates and inserts a new menu. This method allows you to create menus during run-time.

 

Syntax

[ mnu = ] Object.InsertMenu ( sName, sCaption, enMenuType, [bVisible], [vNameOrIndex] )

The InsertMenu method syntax has the following parts:

 

Name

Type

Description

Object

AMenu

AMenu object

sName

Val BString

Menu name

sCaption

Val BString

Menu caption

enMenuType

Val enumAMenuType

Menu type

bVisible

Val Bool

Optional. Visible flag - TRUE is default

vNameOrIndex

Val Variant

Optional. Menu's name or index to insert at. Insert at the end if not entered.

mnu

AMenu

Menu object created and inserted

Comments

This method does not apply to the top-level menu of type amenuTypeBar.

Example

The following statements create an separator and an item:

 

! create separator

mnu=mnuParent.InsertMenu("sSeparator1", "", amenuTypeSeparator)

 

! create menu item

mnu=mnuParent.InsertMenu(sMenuName, sMenuCaption, amenuTypeItem)

 

! set menu properties...

mnu.Checked=GetCommandStatus(stMenu.enCmd, ateCmdStatusChecked)

mnu.Prompt=GetCommandMember(stMenu.enCmd, ateCmdDescription)

mnu.Picture=m_frmMain.imglSmall.Images(s).ExtracIcon()

 

! add handler for OnClick()

AddHandler mnu.OnClick, OnMenuClick

 

The following example shows the procedure AddHandler attached.  The procedure must have the first parameter Val of the control:

 

Procedure OnMenuClick(mnu): Void
--------------------------------------------------------------------------------

mnu: Val AMenu

stMenu: structMenu

{

! create menu popup

stMenu=mnu.Tag

....

}

Applies to

AMenu

See Also

Move, RemoveMenu, AddHandler