Modify the Toolbar

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

The Toolbar is initially defined by a default Genero Toolbar file (dbapp.4tb) located in the styles sub-directory of the template set directory.

Modify the default toolbar

Changes made to the default Toolbar 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 Toolbar (.4tb) and click OK.
    An untitled Genero Toolbar file with a .4tb extension displays in the central workspace. This file is based on the default Toolbar file for the selected template set.
  4. Modify the Toolbar file by adding, modifying, or deleting actions.
    For details regarding the syntax of a Genero Toolbar file, see the Genero Business Development Language User Guide.
  5. Save the modified file to your project as dbapp.4tb.
    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 toolbar at the Form level

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

See Modify the Toolbar for instructions on adding a toolbar to your Form Definition file.

Configure a toolbar using the "On Open Form" code event

Use the On Open Form code event to specify a Toolbar file to use for the form, regardless of how that form is called.

For details regarding the syntax of a Genero Toolbar 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 the basics for the dlgEvent_OnOpenForm function.
  4. Update the dlgEvent_OnOpenForm function to load a custom Toolbar file.
    In this code sample, the highlighted code loads a Toolbar file named "myToolBar.4tb".
    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.loadToolBar, see the Genero Business Development Language User Guide.

Hide a Toolbar using a Window style

To hide a Toolbar on a form, use the "toolBarPosition=none" window style.

For example, to hide the toolbar on all zoom form, you would modify the default style file to include "toolBarPosition=none" for the "Window.zoom_dbapp" window style.

<Style name="Window.zoom_dbapp">
   <StyleAttribute name="windowType" value="modal" />
   <StyleAttribute name="actionPanelPosition" value="top" />
   <StyleAttribute name="ringMenuPosition" value="top" />
   <StyleAttribute name="toolBarPosition" value="none" />
</Style>
See Modify styles for instructions on modifying the default style file.

Hide a toolbar using the "On Open Form" code event

Use the On Open Form code event to specify a Toolbar 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 hide the toolbar using the libdbapp_utilRemoveToolBar method.
    In this code sample, the highlighted code hides the Toolbar.
    PUBLIC FUNCTION dlgEvent_OnOpenForm(currentForm ui.Form)
        CALL libdbapp_utilRemoveTopMenu(currentForm)
        CALL libdbapp_utilRemoveToolBar(currentForm)
    END FUNCTION