Silverfrost Logo About Us | Contact Us

Dynamic Menus

If you wish to add or remove menu items whilst the program is running then this is possible with the aid of a handle:

i=winio@('%mn[&Window[*]] &', handle)

The asterisk (*) causes %mn - Menu to provide a handle that is passed to either add_menu_item@ or remove_menu_item@. Note that items are added to the end of the pop-down menu that contains the handle. You may have a number of handles for various pop-down menus.

Only one handle is required to create a menu with multiple entries. To detect which menu entry has been selected use clearwin_string@('CURRENT_MENU_ITEM') to obtain the text of the menu item selected.

Here is some sample code that illustrates how to add a list of files to a file menu.

      INCLUDE <windows.ins>
      INTEGER i,handle,ctrl,cb,cb0
      CHARACTER*129 fname
      EXTERNAL cb,cb0
      COMMON ctrl
      i=winio@('%mn[[Open]]&',   cb)
      i=winio@('%mn[[Save,|]]&', cb)
      DO i=1,3
        WRITE(fname,'(a,I1)') 'File',i
        CALL add_menu_item@(handle,fname,1,0,cb)
      CALL add_menu_item@(handle,CHAR(0),0,0,cb)
      CALL add_menu_item@(handle,'Exit', 1,0,cb0)
      INCLUDE <windows.ins>
      INTEGER ctrl
      COMMON ctrl
      CALL window_update@(ctrl)



Copyright © 1999-2018 Silverfrost Limited