User Tools

Site Tools


k13:k13.1:k13.1.3:start

13.1.3 Source code - Form. class

' Gambas class file
 
Public Sub Form_Open()
 
  FMain.Center
  FMain.Resizable = False
  PictureBox1.Border = Border.None
  PictureBox1.Picture = Picture["muster.jpg"]
  Label1.text = "Fractal Geometry (Computer Science Course 12)"
  FMain.Height += 24 ' Space must be created for the menu bar
 
  MM.ShowMenu
 
End ' Form_Open()
 
Public Sub ImageOpen()
 
  Dialog.Title = "Import a image file!"
  Dialog.Filter = ["*.png", "image files"]
 
  If Dialog.OpenFile(False) = True Then ' Multiselect=False (Standard)
     Message.Info("The opening of the image file was cancelled!")
     Return ' Cancel button pressed
  Else
     Try PictureBox1.Picture = Picture.Load(Dialog.Path)
     If Error Then
        Message.Error("Error opening the image file")
     Else
        Label1.Alignment = Align.Left
        Label1.Text = " File: " & File.Name(Dialog.Path)
     Endif ' ERROR?
  Endif ' Dialog.OpenFile
 
End ' ImageOpen()
 
Public Sub CreateImage()
  Message.Info("A programme is called up to generate an image file..")
End '  CreateImage()
 
Public Sub SaveImage()
  Message.Info("Call: Save dialogue")
End ' SaveImage()
 
Public Sub SaveAsDialog()
  Message.Info("Call: Save sub-dialogue")
End ' SaveAsDialog()
 
Public Sub PrintImage()
  Message.Info("Now the image is printed ...")
End ' PrintImage()
 
Public Sub SetOptions()
   Message.Info("Programme options can be set here...")
End ' SetOptions()
 
Public Sub GetColor_1()
  Message.Info("A colour selection dialogue 1 is called up here.")
End ' GetColor1()
 
Public Sub GetColor_2()
  Message.Info("A colour selection dialogue 2 is called up here.")
End ' GetColor1()
 
Public Sub Form_Close()
  FHelp.Close
  FMain.Close
End ' Form_Close()

Comments:

  • In line 12, the menu is inserted into the form declared in the module MM. module.
  • The other source code does not contain any special features. The program actions are mainly coded, which are triggered when a certain menu is clicked or the assigned key combination.
  • The procedures contain - except for ImageOpen () - only references to the program action.

In the download area you will find 3 projects with the same goal. For the first project, the file Form. class contains the complete source code. A module is used in the second project and the third project works with functions within a module. This makes the source code shorter, but also more complicated in the syntax when declaring individual menus.

13.1.3 Download

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k13/k13.1/k13.1.3/start.txt · Last modified: 02.02.2022 (external edit)

Page Tools