User Tools

Site Tools


menubar_declare_a_pulldown_menu_.htm
Navigation:  Language Reference > 6 - Windows > ====== MENUBAR (declare a pulldown menu) ====== Previous pageReturn to chapter overviewNext page

NewC7.jpg

MENUBAR [,USE( )] [, NOMERGE ]
[ MENU( )
[ ITEM( ) ]
[ MENU( )
[ ITEM( ) ]
END ]
END ]
[ ITEM( ) ]
END

blk2blue.jpg

MENUBAR Declares the menu for an APPLICATION or WINDOW.
USE A field equate label to reference the menubar structure in executable code(PROP:USE). PROP:MenuBar can also be used at runtime to get the Field Equate Label.
NOMERGE Specifies menu merging behavior.
MENU A menu item with an associated drop box containing other menu selections.
ITEM A menu item for selection.

The MENUBAR structure declares the pulldown menu selections displayed for an APPLICATION or WINDOW. MENUBAR must appear in the source code before any TOOLBAR or controls.

On an APPLICATION, the MENUBAR defines the Global menu selections for the program. These are active and available on all MDI “child” windows (unless the window's own MENUBAR structure has the NOMERGE attribute). If the NOMERGE attribute is specified on the APPLICATION's MENUBAR, then the menu is a local menu displayed only when no MDI child windows are open and there is no global menu.

On an MDI WINDOW, the MENUBAR defines menu selections that are automatically merged with the Global menu. Both the Global and the window's menu selections are then active while the MDI “child” window has input focus. Once the window loses focus, its specific menu selections are removed from the Global menu. If the NOMERGE attribute is specified on an MDI WINDOW's MENUBAR, the menu overwrites and replaces the Global menu.

On a non-MDI WINDOW, the MENUBAR is never merged with the Global menu. A MENUBAR on a non-MDI WINDOW always appears in the WINDOW, not on any APPLICATION which may have been previously opened.

Events generated by local menu items are sent to the WINDOW's ACCEPT loop in the normal way. Events generated by global menu items are sent to the active event loop of the thread which opened the APPLICATION (in a normal multi-thread application this means the APPLICATION's own ACCEPT loop).

Dynamic changes to menu items which reference the currently active window affect only the currently displayed menu, even if global items are changed. Changes made to the Global menu items when the APPLICATION is the current window, or which reference the global APPLICATION window affect the global portions of all menus, whether already open or not.

When a WINDOW's MENUBAR is merged into an APPLICATION's MENUBAR, the global menu selections appear first, followed by the local menu selections, unless the FIRST or LAST attributes are specified on individual menu selections.

A two-column drop menu can be achieved by assigning PROP:Max = 1 to the ITEM which should begin the second column.

Example:

    !An MDI application frame window with main menu for the application:
    MainWin APPLICATION('My Application')
       MENUBAR
        MENU('File'),USE(?FileMenu)
         ITEM('Open...'),USE(?OpenFile)
         ITEM('Close'),USE(?CloseFile),DISABLE
         ITEM('E&xit'),USE(?MainExit),LAST
        END
        MENU('Edit'),USE(?EditMenu)
          ITEM('Cu&t'),USE(?CutText),KEY(CtrlX),STD(STD:Cut),DISABLE
          ITEM('Copy'),USE(?CopyText),KEY(CtrlC),STD(STD:Copy),DISABLE
          ITEM('Paste'),USE(?PasteText),KEY(CtrlV),STD(STD:Paste),DISABLE
        END
        MENU('Window'),STD(STD:WindowList),LAST
          ITEM('Tile'),STD(STD:TileWindow)
         ITEM('Cascade'),STD(STD:CascadeWindow)
        END
        MENU('Help'),USE(?HelpMenu),LAST
         ITEM('Contents'),USE(?HelpContents),STD(STD:HelpIndex)
         ITEM('Search for Help On...'),USE(?HelpSearch),STD(STD:HelpSearch)
         ITEM('How to Use Help'),USE(?HelpOnHelp),STD(STD:HelpOnHelp)
         ITEM('About MyApp...'),USE(?HelpAbout)
        END
       END
      END

    !An MDI child window with menu for the window, merged into the
    ! application's menubar:
    MDIChild WINDOW('Child One'),MDI
       MENUBAR
         MENU('File'),USE(?FileMenu)      !Merges into File menu
          ITEM('Pick...'),USE(?PickFile)    !Added to menu selections
         END
         MENU('Edit'),USE(?EditMenu)      !Merges into Edit menu
          ITEM('Undo'),USE(?UndoText),KEY(CtrlZ),STD(STD:Undo) !Added to menu
         END
        END
        TEXT,HVSCROLL,USE(Pre:Field)
        BUTTON('&OK'),USE(?Exit),DEFAULT
       END

    !An MDI window with its own menu, overwriting the main menu:
    MDIChild2 WINDOW('Dialog Window'),MDI,SYSTEM,MAX,STATUS
       MENUBAR,NOMERGE
         MENU('File'),USE(?FileMenu)
          ITEM('Close'),USE(?CloseFile)
         END
         MENU('Edit'),USE(?EditMenu)
          ITEM('Undo'),USE(?UndoText),KEY(CtrlZ),STD(STD:Undo)
          ITEM('Cu&t'),USE(?CutText),KEY(CtrlX),STD(STD:Cut)
          ITEM('Copy'),USE(?CopyText),KEY(CtrlC),STD(STD:Copy)
          ITEM('Paste'),USE(?PasteText),KEY(CtrlV),STD(STD:Paste)
         END
        END
       TEXT,HVSCROLL,USE(Pre:Field),MSG('Enter some text here')
        BUTTON('&OK'),USE(?Exit),DEFAULT
       END

    !A non-MDI window with its own menu:
    NonMDI WINDOW('Dialog Window'),SYSTEM,MAX,STATUS
       MENUBAR
        MENU('File'),USE(?FileMenu)
         ITEM('Close'),USE(?CloseFile)
        END
        MENU('Edit'),USE(?EditMenu)
         ITEM('Undo'),USE(?UndoText),KEY(CtrlZ),STD(STD:Undo)
         ITEM('Cu&t'),USE(?CutText),KEY(CtrlX),STD(STD:Cut)
         ITEM('Copy'),USE(?CopyText),KEY(CtrlC),STD(STD:Copy)
         ITEM('Paste'),USE(?PasteText),KEY(CtrlV),STD(STD:Paste)
        END
       END
       TEXT,HVSCROLL,USE(Pre:Field),MSG('Enter some text here')
       BUTTON('&OK'),USE(?Exit),DEFAULT
      END

See Also: Menubar Item

menubar_declare_a_pulldown_menu_.htm.txt · Last modified: 2021/04/15 14:27 by carlbarnes