Creating A menu on the fly (OpenInsight 32-bit Specific)
At 22 OCT 2002 12:36:29AM Peter Walter wrote:
All,
I am converting an AREV application in which the entire window menu structure had been created on-the-fly from a menu database, depending on the permissions of the logged-in user. I wish to translate this functionality to an OI MDI window where the menu structure of the MDI frame is created (and recreated as necessary) on the fly. The number of menu entries is unknown at design time, and the menus contain an unknown number of cascading entries. Would anyone who has done similar code please share their solution with me?
Thanks in advance,
Peter Walter
At 22 OCT 2002 11:30AM Richard Hunt wrote:
Hi Peter,
I am not an expert in this, although it works for me when I want to set up a floating menu for a right click event on an edittable.
Here is the menu structure information you need to know about…
FALSE$=0
TRUE$=1
NOTHING$='
WINDOW=@WINDOW
STRUCTURE=NOTHING$
STRUCTURE=WINDOW:'.MENU' * The name of the control. STRUCTURE=NOTHING$ * The class of the control.
STRUCTURE=MENU' * The type of the control. STRUCTURE=WINDOW * The parent of the control.
STRUCTURE=NOTHING$ * Leave blank. - - - - - - - - - - - - - - - - Now values 6 and beyond are for the actual menu items. - - - - - - - - - - - - - - - - Here is the menu item structure information you need to know about… ITEM=NOTHING$ ITEM=POPUP' or 'ITEM' * Popup for the horizontal menu item. Item for the vertical menu item.
ITEM=FALSE$ * True / false flag if this is the last popup or item. ITEM=FILE' * The name of the menu item control.
ITEM=File' * The display text of the menu item. ITEM=FALSE$ * True / false flag for disabled.
ITEM=FALSE$ * True / false flag for checked (check mark before text). ITEM=FALSE$ * True / false flag for hidden.
ITEM=1024 + 70 * Accelerator key (1024 for ALT) (70 for F). ITEM=Help for file.' * Help text for menu item.
ITEM=2*':APPID:'*OMNIEVENT*':WINDOW:'.ET_1' * The event handler for the menu item. ITEM=NOTHING$ * The menu item style. I just leave this blank.
- - - - - - - - - -
So code for a simple menu would be like this…
* Declare statements.
DECLARE FUNCTION UTILITY
*
* Set program variables. FALSE$=0 TRUE$=1 NOTHING$=' WINDOW=@WINDOW *
* Set up main menu structure.
STRUCTURE=NOTHING$
STRUCTURE=WINDOW:'.MENU'
STRUCTURE=NOTHING$
STRUCTURE=MENU'
STRUCTURE=WINDOW
STRUCTURE=NOTHING$
*
* Set up vertical menu item one. ITEM=NOTHING$ ITEM=POPUP' ITEM=FALSE$ ITEM=P1 ITEM=Popup One' ITEM=FALSE$ STRUCTURE=ITEM *
* Set up horizontal menu item 1 for vertical menu item 1.
ITEM=NOTHING$
ITEM=ITEM'
ITEM=TRUE$
ITEM=P1I1'
ITEM=Popup 1 Item 1'
ITEM=FALSE$
ITEM=TRUE$
ITEM=FALSE$
ITEM=256 + 65
ITEM=Help text for popup one, item one.'
ITEM=2*':@APPID:'*OMNIEVENT*':@WINDOW:'.EDITLINE_1'
STRUCTURE=ITEM
*
* Set up vertical menu item 2. ITEM=NOTHING$ ITEM=POPUP' ITEM=FALSE$ ITEM=P2 ITEM=Popup 2' ITEM=FALSE$ STRUCTURE=ITEM *
* Set up horizontal menu item 1 for vertical menu item 2.
ITEM=ITEM'
ITEM=FALSE$
ITEM=P2I1
ITEM=Popup 2 Item 1'
ITEM=FALSE$
STRUCTURE=ITEM
*
* Set up horizontal menu item 2 for vertical menu item 2. ITEM=ITEM' ITEM=TRUE$ ITEM=P2I2 ITEM=Popup 2 Item 2' ITEM=FALSE$ STRUCTURE=ITEM *
* Set up vertical menu item 3.
ITEM=NOTHING$
ITEM=POPUP'
ITEM=TRUE$
ITEM=Popup 3'
ITEM=Popup 3'
ITEM=FALSE$
STRUCTURE=ITEM
*
* Set up horizontal menu item 1 for vertical menu item 3. ITEM=ITEM' ITEM=FALSE$ ITEM=P3I1' ITEM=Popup 3 Item 1' ITEM=FALSE$ STRUCTURE=ITEM *
* Set up horizontal menu item 2 for vertical menu item 3.
ITEM=ITEM'
ITEM=FALSE$
ITEM=P3I2'
ITEM=Popup 3 Item 2'
ITEM=FALSE$
STRUCTURE=ITEM
*
* Set up horizontal menu item 3 for vertical menu item 3. ITEM=ITEM' ITEM=TRUE$ ITEM=P3I3' ITEM=Popup 3 Item 3' ITEM=FALSE$ STRUCTURE=ITEM *
* Create the menu control.
DECLARE FUNCTION UTILITY
RESULT=UTILITY('CREATE',STRUCTURE)
At 23 OCT 2002 07:52PM Peter Walter wrote:
Richard,
Thank you very much. I appreciate your help.
Peter