Question

I have a Windows application written in Progress. I'm working with version 10.1C. I would like to add MRU functionality to the menu, i.e. I want to add, remove and modify menu items in the application's File menu, to show the user's most recent files in the order in which they were used. I've done this often enough in a number of other languages, it's a pretty common feature and very easy to do.

But how would one do this in Progress? In another language I could have created 10 menu items and simply made the unused ones invisible, but you can't do that in Progress. I can't imagine why.

Alternatively, I should be able to dynamically create menu items as needed and add them to the end of the MRU list in the File menu, but I can't seem do that either: Firstly, I can't specify where in the File menu the item must be added, it always adds it to the bottom, and secondly, I can't add dynamic menus to static menus, so I can't add my MRU menus to the existing File menu. I can do it if I make the whole File menu dynamic (which I really don't want to do), but then I can't add the dynamic File menu to the static menu bar. This leaves me with the unacceptable option of making the entire menu structure dynamic.

Does anybody have any ideas?



Using Ade's answer below, here is a brief example of how I achieved it. Changing the labels and values of the MRU items doesn't require any fiddling, just set the appropriate attributes, but in order to add new MRU items, I have to remove and recreate the Exit menu item:

/* Remove the RULE and Exit menu items */
IF VALID-HANDLE(ghMenuRule) THEN DELETE OBJECT ghMenuRule.
IF VALID-HANDLE(ghMenuExit) THEN DELETE OBJECT ghMenuExit.

/*

...
Coding to add MRU items.
...

*/


/* Create the RULE and Exit menu items */
CREATE MENU-ITEM ghMenuRule
  ASSIGN
    SUBTYPE = "RULE"
    PARENT    = MENU m_File:HANDLE IN MENU MENU-BAR-C-Win.

CREATE MENU-ITEM ghMenuExit
  ASSIGN
    PARENT    = MENU m_File:HANDLE IN MENU MENU-BAR-C-Win
    LABEL     = "E&xit"
  TRIGGERS:
      ON CHOOSE PERSISTENT RUN ExitApp IN THIS-PROCEDURE.
  END TRIGGERS.

The actual MRU items are created just like the Exit menu is created here, except that I store the handles in a temp-table.

The result is a menu like this:

        File
          New
          Open
          --------
          Print Setup
          Print
          --------
          1 Mru item 
          2 Mru Item
          3 Mru Item
          --------
          Exit
Was it helpful?

Solution

create a static menu MENU-BAR-C-Win.

add static sub-menu "File" m_file.

add static menu-item (use ">>") "Exit" (m_Exit) to m_file.

define.... DEFINE VARIABLE hMRU#1 AS HANDLE NO-UNDO.

create a button to dynamically...

  CREATE MENU-ITEM hMRU#1
  ASSIGN
    PARENT    = MENU m_File:HANDLE IN MENU MENU-BAR-C-Win
    LABEL     = "MRU#1"
  TRIGGERS:
      ON CHOOSE PERSISTENT RUN SomeThing IN THIS-PROCEDURE.
  END TRIGGERS.

you'll want to keep track of your handles (temp-table?) some how.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top