13.7.2 Project MenuButton

The complete project can be found in the download area. The source code of FMain.class is specified here. The code consistently implements the above-mentioned remarks and notes:

[1] ' Gambas class file
[2]
[3] Public Sub Form_Open()
[4]
[5]   FMain.Center
[6]   FMain.Resizable = False
[7]   PictureBox1.Border = Border.None
[8]   PictureBox1.Picture = Picture["fractal.jpg"]
[9]   Label1.Text = "Fractal Geometry - Computer Science Course 2012"
[10]   ToolBar1.H = 24
[11]
[12]   mnubtnFile.Width = 48
[13]   mnubtnFile.H = 24
[14]   mnubtnFile.Picture = Picture["icon:/16/options"]
[15]   mnubtnFile.Menu = "mnuFile"
[16]   mnubtnFile.Tooltip = "File-Operationes"
[17]   mnubtnFile.MenuOnly = False
[18]
[19]   mnubtnHelp.Width = 72
[20]   mnubtnHelp.H = 24
[21]   mnubtnHelp.Text = "Hilfen"
[22]   mnubtnHelp.Menu = "mnuHelp"
[23]   mnubtnHelp.MenuOnly = True
[24]
[25]   toolbtnClose.Picture = Picture["icon:/16/quit"]
[26]   toolbtnClose.Tooltip = "Quit Program"
[27]
[28] End ' Form_Open()
[29]
[30] Public Sub Form_Close()
[31]   FHelp.Close
[32]   FMain.Close
[33] End ' Form_Close()
[34]
[35] 'Own Program Actions -----------------------------------------------------------
[36]
[37] Public Sub OpenImage()
[38]
[39]   Dialog.Title = "Import an image file!"
[40]   Dialog.Filter = ["*.png", "image files"]
[41]
[42]   If Dialog.OpenFile(False) = True Then ' Multiselect=False (Standard)
[43]      Message.Info("The opening of the image file was cancelled!")
[44]      Return ' Cancel button pressed
[45]   Else
[46]      Try PictureBox1.Picture = Picture.Load(Dialog.Path)
[47]      If Error Then
[48]         Message.Error("Error when opening the image file")
[49]      Else
[50]         Label1.Alignment = Align.Left
[51]         Label1.Text = " File: " & File.Name(Dialog.Path)
[52]      Endif ' ERROR?
[53]   Endif ' Dialog.OpenFile
[54]
[55] End ' OpenImage()
[56]
[57] Public Sub PrintImage()
[58]   Message.Info("The image is printed (print routine)!")
[59] End ' PrintImage()
[60]
[61] ' Menu-Actions -----------------------------------------------------------
[62]
[63] Public Sub mnu11Open_Click()
[64]   OpenImage()
[65]   mnu13Print.Enabled = True
[66] End ' mnu11Open_Click()
[67]
[68] Public Sub mnu13Print_Click()
[69]   PrintImage()
[70]   mnu13Print.Enabled = False
[71] End ' mnu13Print_Click()
[72]
[73] Public Sub mnu21Help_Click()
[74]   FHelp.Show
[75] End ' mnuHelp_Click()
[76]
[77] Public Sub mnu22Information_Click()
[78]   Desktop.Open("http://www.gambas-buch.de/dw/doku.php?id=k13:start")
[79] End ' mnu32Information_Click()
[80]
[81] Public Sub toolbtnClose_Click()
[82]   FMain.Close
[83] End ' toolbtnClose_Click()
[84]
[85] Public Sub mnubtnFile_Click()
[86]   Message.Info("Click on symbol ---> Call sub-programme or help text ...\nClick on the small black arrow ---> View menu list.")
[87] End ' mnubtnFile_Click()

MenuButton
Figure 13.7.2.1: MenuButton in use

Comments:

13.7.3 Download

Project

Download