Modify the Top Menu

Generated applications provide a default Top Menu for its forms. You have several options for changing – or hiding – the Top Menu.

With the Business Application Modeler, a Top Menu is initially defined by a default Genero Top Menu file (dbapp.4tm) located in the styles sub-directory of the template set directory.

Modify the default Top Menu

Changes made to the default Top Menu will be global to all forms in the project.

  1. Select File > New.
    The Select an item dialog opens.
  2. Select Genero BAM Desktop.
  3. Under the Resources section, select Top Menu (.4tm) and click OK.
    An untitled Genero Top Menu file with a .4tm extension displays in the central workspace. This file is based on the default Top Menu file for the selected template set.
  4. Modify the Top Menu file by adding, modifying, or deleting actions.
    For details regarding the syntax of a Genero Top Menu file, see the Genero Business Development Language User Guide.
  5. Save the modified file to your project as dbapp.4tm.
    Save this file in the $(ProjectDir)/resources directory and under the Resources node in your Project. See BAM Projects for best practices recommendations regarding the organization of files in your BAM project.
    Saving your file using this name ensures that Genero Studio will use your file at runtime, replacing the template default.

Configure a Top Menu at the Form level

With Form Designer, you can add a top menu to a form. A Top Menu defined in the form itself will take precedence over the default Top Menu defined for the project or template set.

See Modify the Top Menu for instructions on adding a Top Menu to your Form Definition file.

Configure a Top Menu using the "On Open Form" code event

Use the On Open Form code event to specify a Top Menu file to use for the form.

For details regarding the syntax of a Genero Top Menu file, see the Genero Business Development Language User Guide.

  1. Open the Form Definition file.
  2. In the Form Structure view, select on the managedForm node.
  3. In the Properties view, locate the On Open Form code event in the Dialog Events group; then click on the arrow icon.
    This opens the necessary Genero source (.4gl) file for editing, and provides a template for the dlgEvent_OnOpenForm function.
  4. Update the dlgEvent_OnOpenForm function to load a custom Top Menu file.
    In this code sample, the highlighted code loads a Top Menu file named "myTopMenu.4tm".
    PUBLIC FUNCTION dlgEvent_OnOpenForm(currentForm ui.Form)
    
        DISPLAY "dlgEvent_OnOpenForm (Form scope) is raised"
        
        CALL currentForm.loadToolBar("myToolBar")
        CALL currentForm.loadTopMenu("myTopMenu")
    
    END FUNCTION
    For more information on ui.Form.loadTopMenu, see the Genero Business Development Language User Guide.

Hide a Top Menu using the "On Open Form" code event

Use the On Open Form code event to specify a Top Menu file to use for the form.

  1. Open the Form Definition file.
  2. In the Form Structure view, select on the managedForm node.
  3. In the Properties view, locate the On Open Form code event in the Dialog Events group; then click on the arrow icon.
    This opens the necessary Genero source (.4gl) file for editing, and provides the basics for the dlgEvent_OnOpenForm function.
  4. Update the dlgEvent_OnOpenForm function to provide code to hide the Top Menu.
    The code you write will need to perform basic manipulation of the AUI tree to remove the Top Menu. To learn the code for manipulating the AUI tree, see the Genero Business Development Language User Guide.