If you want to use one or more MenuButtons in a project on a form, the following notes must be observed:
First you should place the MenuButton in a container. A ToolBar is well suited for a (horizontal) toolbar:
Figure 13.7.1.1: Two MenuButtons in one toolbar
Then the individual menus are to be designed and most safely declared with the MenuEditor in the desired structure:
Figure 13.7.1.2: Menu editor with the individual menus
Make sure to set the .Visible property for the menus in the top level of the hierarchy (image file and help) to False so that they do not appear on the form. For each menu in the menu list - except for the menu mnuSpace - the property .Caption must be set to a string that is not empty; even if this character string is not displayed, otherwise a hyphen will be generated! You can assign a suitable icon to each menu.
Afterwards, the actions that are triggered when a certain menu is activated by a click must be described in the source code. Here is a corresponding extract from a source text:
Public Sub mnu11Open_Click() OpenImage() mnu13Print.Enabled = True End ' mnu11Open_Click() Public Sub mnu13Print_Click() PrintImage() mnu13Print.Enabled = False End ' mnu13Print_Click()
Finally, the mentioned actions OpenImage() and PrintImage() have to be coded, which basically determine the functionality of the program:
' Eigene Programm-Aktionen Public Sub OpenImage() Dialog.Title = "Import an image file!" Dialog.Filter = ["*.png", "Image files"] If Dialog.OpenFile(False) = True Then Message.Info("The opening of the image file was cancelled!") Return ' Cancel-Button pressed ... Endif ' Dialog.OpenFile End ' OpenImage() Public Sub PrintImage() Message.Info("The image is printed (print routine is called up)!") End ' PrintImage()