Silverfrost Logo About Us | Contact Us
 

Menu format - %mn[menu_specification]

%mn is used to attach a menu to the window. This is best illustrated by an example:

  i=winio@('%mn[&Alpha,&Beta[Beta1,Beta2,|,Beta3],&Gamma]',
+         cb1,cb2,cb3,cb4,cb5)

This format specifies five selectable items, three of which, Beta1, Beta2, and Beta3 are contained in a drop-down menu. A bar symbol ( | ) between Beta2 and Beta3 causes a separator to be drawn in the drop-down menu. The three top-level menu items (Alpha, Beta and Gamma) can be selected using accelerator keys Alt-A, Alt-B and Alt-G that are specified by the inclusion of the ampersand character (&) placed to the left of the character chosen to be the (unique) accelerator for this menu (a double ampersand (&&) is required if you want an ampersand to appear in the text). Five call-back functions are required as arguments corresponding to each selectable menu item. A call-back function is called when the corresponding menu item is selected.

Individual menu items may also be greyed (so that they are visible, but not usable). In order to grey an item, prefix its name with a tilde (~) and insert an INTEGER argument to provide a control integer. When the value of this integer is zero, the item is greyed and disabled, otherwise it is enabled. Note that it is not necessary to use a different control integer for every item. You can use one integer to control several menu items and/or buttons. The following example illustrates a 3-item menu, in which the middle item is greyed:

      WINAPP
      INCLUDE <windows.ins>
      INTEGER drinker
      EXTERNAL squash_func,beer_func,tea_func
      drinker=0
      i=winio@('%mn[Squash]&',squash_func)
      i=winio@('%mn[~Beer]&',drinker,beer_func)
      i=winio@('%mn[Tea]',tea_func)
      END
c---- call back function ---
      INTEGER FUNCTION squash_func()
      squash_func=1
      END
      ......

The hash character (#) is used to control the placement of a check mark (tick) at the front of a menu item. The corresponding control variable is set to the value 1 in order to display a check mark otherwise it is set to zero. Top level menu items cannot be checked.

As an alternative to using the ampersand (&) before a character, an accelerator key may also be associated with a menu item and its corresponding call-back function as illustrated in the following example.

i=winio@('%mn[File[Open^Ctrl+F12]]',open_func)

The caret symbol ^ is used here as an alias for the tab character (CHAR(9)) and is followed by the key name. Valid key names are illustrated with the accelerator key format %ac below. The use of an accelerator key is is only permitted in sub-menus and should not be used in top level menus.

In order to continue a menu in a new winio@ statement, it is necessary to match opening square brackets with closing brackets on the line to be continued. Then use an appropriate number of opening square brackets on the next line. For example:

i=winio@('%mn[Test,File[Open]]&',f1,f2)
i=winio@('%mn[[Save],Help]',f3,f4)

is equivalent to

i=winio@('%mn[Test,File[Open,Save],Help]',f1,f2,f3,f4)

Help strings are provided by inserting a question mark (%?mn). All the strings are placed in order at the end of the format description, one for each item that has a call-back function. For example,

 i=winio@('%?mn[File[New]][Start a new file]&',newfn)
 i=winio@('%?mn[[Save]][Save this file]',savefn)

Separators also require a help string but this is not used.

 

 

Copyright © 1999-2017 Silverfrost Limited