User Tools

Site Tools


k13:k13.7:k13.7.2:start

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:

  • If you set the .MenuOnly property of a MenuButton (line 18) to the value False, then you can start a program (lines 85 to 87) by clicking on the icon (1), while a click on the small black arrow (2) opens the menu list.
  • With the 2nd MenuButton 'Help', a click on the MenuButton - regardless of icon, text or arrow on the MenuButton - calls up a menu list with which you can call up a local help (Alternative F1) or a global help (Internet), as you can see in → Figure 13.7.2.1.
  • Click on the ToolButton (3) in the toolbar to close the program.

13.7.3 Download

Project

Download

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.
k13/k13.7/k13.7.2/start.txt · Last modified: by 127.0.0.1