Silverfrost Logo About Us | Contact Us

Enhanced menus

See New enhanced menus for a simpler alternative.

A ClearWin+ window can have an enhanced standard menu (%`mn) as an alternative to a standard (%mn - Menu) menu. Enhanced popup menus (%`pm) are also available. An enhanced menu has more possibilities such as bitmap entries and is more flexible for programs that update menus on the fly or read them from configuration files. Any window can be given either a normal menu or an enhanced menu.

%`mn and %`pm each take one character argument, that describes the entire menu, and one call-back function that is used for all menu events.


INTEGER i,winio@,cbfunc
INCLUDE <windows.ins>
CHARACTER*16 menuitem
IF(menuitem.EQ.'File~Exit') cbfunc=0
openbmp BITMAP open.bmp

The character string fmt illustrates a typical enhanced menu definition:


Here the '&' character performs the same accelerator key function as for standard menus. Special options preceded by a minus sign are available as follows:


Represents a bitmap (loaded from a resource named xxx). In the example, the text 'Open' is part of the bitmap (the font is 8pt MS Sans Serif).


Menu separator


Subsequent item is greyed out


Subsequent item is checked


Subsequent item has help information given between square brackets. This information can include newline characters.


Subsequent item has a radio button placed in front of it.

Notice that sub-menus are specified using nested square brackets - just as they are for standard menus.

The call-back function is invoked when the user selects a menu event. This function uses CLEARWIN_STRING@('CURRENT_MENU_ITEM') to determine which event is required. In the given example, when the user selects 'Exit' the string 'File~Exit' is returned. Strings are separated by a tilde '~' character and any '&' characters in the menu names are left in place. In the given example, selecting 'Open' generates 'File~openbmp'. (Menu items often represent recently opened files. File names might contain tilde '~' characters, however no ambiguity will occur because such items will always appear in terminal positions in the menu tree structure.)

Newline and carriage return characters are ignored between menu items. This means that a menu structure can conveniently be defined in a text file, read in and presented as an enhanced menu.

If an enhanced menu is to be altered (whether it be to alter the grey/check status of an item, or to add/remove entries etc.) the menu is simply replaced using one of the calls:


where HANDLE is an integer that is the (%hw - Handle) window handle of the parent window and MENU is the replacement character argument. HANDLE can be zero, in which case the most recently created window is updated. It is an error to call these routines for a window that does not use %`mn or %`pm.



Copyright © 1999-2019 Silverfrost Limited