Menus

Purpose

To create, edit and delete window specific bar menus.

Syntax

Menu m$()

Menu idx, flags, txt$

state = Form.MenuEnabled
Form.MenuEnabled = state

retval = Form.MenuItem(idx)
Form.MenuItem(idx) = setval

Menu Kill

txt$ = Form.MenuText(idx)
Form.MenuText(idx) = txt$

Sub Form_MenuEvent([index%,] idx%)

Sub Form_MenuOver([index%,] idx%)

m$(): the string array containing the menu entries
flags, idx, index: integer
retval, setval: boolean, integer or string
state: boolean
txt$: string

Description

Menu bars can be created in a window by using Menu m$() and, subsequently, edited using the Menu idx, flags, txt$ command or the MenuItem and MenuText properties of the window itself. The enabled status of the menu itself (rather than the individual items) can be controlled using the MenuEnabled property, all menu events are handled by MenuEvent and MenuOver and the menu in the current window can be destroyed by the command Menu Kill.

Creating Menus using Menu m$() Show

Adding Items and Sub-Menus to Existing Menus Show

Editing Menu Item Properties using Menu idx, flags, txt$ Show

Viewing and Setting Menu Item Properties using MenuItem(idx) Show

Viewing and Setting Menu Item Properties using APIs Show

Viewing and Setting Menu Labels using MenuText(idx) Show

Handling Menu Events Show

Removing Items from Menus Show

Disabling, Enabling and Destroying Menus Show

Examples

The example below creates a basic Menu and shows how items can be changed and events handled using standard GB32 commands. Show

This second example from the original German GFA help file, is a good illustration of how to mix standard GB32 commands and Windows APIs to create and alter menus. Show

Known Issues

As noted above, the MenuItem property of the Form hosting the menu does not work with menu items added through Windows APIs and this is because the MenuItem collection is an internal collection formed by GFA Basic which is created at the same time as the Menu and there is no programmatical means available to add to this collection once it has been created. See this article on Sjouke Hamstra's blog for a more detailed and technical explanation of this issue.

See Also

Popup

{Created by Sjouke Hamstra; Last updated: 20/12/2015 by James Gaite}