dzForm example
Previous  Next

This is an example application using the dzForm library that may be cut and pasted. It requires the B4PPC library Formlib.dll and dzHWDesktop.dll to be added as components.

It requires a form named "Form1 to be created in the Form Designer and the following controls added. Their placement doesn't matter as they are used as the source of controls for another form

A Button named "Button1" showing "Button1"
A Button named "Button2" showing "Show f3 form"
A TextBox named "TextBox1" showing "TextBox1"
A Panel named "Panel1" width = 130 height = 95

It also requires the following objects to be created before running it.

flib: a FormLib
dzfrm: a dzForm
f2: a dzForm
f3: a dzForm
dz: a dzHW
cm: a ContextMenu

Apologies for the small font. Helpmaker, used to create this helpfile, does strange things when changing and resizing fonts including removing colour. I thought it best to retain the familiar colour coding and tolerate the smaller font.

Sub Globals
      
End Sub


Sub App_Start
      
      'dzHW object
      dz.New1

      'dzFrom object
      dzfrm.New1(500,500, "dzForm", "My Form 1 - MDI", true)
      dzfrm.Show
      
      'FromLib object
      'Form1 is a normal B4PPC form. It will never be visible
      'We need it only for it's controls
      flib.New1("Form1", B4PObject(1))
      
      'dzForm object
      f2.New1(200,300, "f2", "My Form 2", false)
      f2.Show

      'dzForm object    
      f3.New1(250,400, "f3", "My Form 3", false)
      f3.Show

      'Make f2 and f3 forms MDIDhildren of dzfrm form
      dzfrm.MakeFormMDIChild(f2.Form)
      dzfrm.MakeFormMDIChild(f3.Form)

      'Use FormLib to change parent
      flib.ChangeParent("Button1", f3.Form)
      
      'Place Button1
      Button1.Left = 0
      Button1.Top = f3.ClientAreaHeight - 40
      Button1.Width = f3.ClientAreaWidth
      Button1.Height = 40

      'use dzForm to change parent
      f2.AddControl("Button2")
      f3.AddControl("TextBox1")
      
      'Place TextBox1
      TextBox1.Left = 0
      TextBox1.Top = 0
      TextBox1.Width = f3.ClientAreaWidth
      TextBox1.Height = f3.ClientAreaHeight - 40

      'use dzForm to change parent
      f2.AddControl("Panel1")
      
      button1.BringToFront

      'Change dzForm properties
      dzfrm.HasMaximizeBox = true
      dzfrm.HasMinimizeBox = true
      dzFrm.IsSizable = true

      'Create a new textbox at panel1 which belongs to f2 form
      AddTextBox("Panel1", "tb1", 10,10,70,20)
      
      'Create a context menu with B4PPC FormLib
      cm.New1
      cm.AddItem("item 1")
      cm.AddItem("item 2")

      'Attach Context Menu to dzfrm
      'Right click everyware in the form to appear
      flib.AddContextMenu(dzfrm.Form, cm.Value)
      
      'Create Main Menu for dzfrm
      dzfrm.MainMenuStart

      dzfrm.ItemMenuStart("File")
      dzfrm.AddMenuItem("File - Item 1")
      dzfrm.AddMenuItem("File - Item 2")
      dzfrm.ItemMenuEnd
      
      dzfrm.ItemMenuStart("Edit")
      dzfrm.AddMenuItem("Edit - Item 1")
      dzfrm.AddMenuItem("Edit - Item 2")
      dzfrm.ItemMenuEnd

      dzfrm.MainMenuEnd
      '*****************
      
      'Run the application
      dzfrm.Run
      'Nothing runs after Run function
End Sub

Sub Button1_Click
      
      Msgbox(TextBox1.Text, "TextBox1 Contents")      
End Sub

Sub dzfrm_FormClosing
      AppClose
End Sub

Sub f2_Click
      f2.BringToFront
      Msgbox("Non MDI form clicked",f2.Name )   
End Sub

Sub f2_Closing
      f2.CancelClose
End Sub

Sub f2_SizeChanged
      panel1.Left = 0
      panel1.top = 0
      panel1.Width = f2.CLientAreaWidth
      panel1.Height = f2.ClientAreaHeight
End Sub

Sub f3_SizeChanged
      textbox1.Text= f3.Left & ", " & f3.Top & ", " & f3.Width & ", " & f3.Height
      
      Button1.Left = 0
      Button1.Top = f3.ClientAreaHeight - 40
      Button1.Width = f3.ClientAreaWidth
      Button1.Height = 40
      
      TextBox1.Left = 0
      TextBox1.Top = 0
      TextBox1.Width = f3.ClientAreaWidth
      TextBox1.Height = f3.ClientAreaHeight - 40
End Sub

Sub f3_Click
      f3.BringToFront
      Msgbox("Non MDI form clicked",f3.Name )   
End Sub

Sub Button2_Click
      f3.Show
End Sub

Sub f3_Closing
      f3.CancelClose
      f3.Hide
End Sub

Sub cm_Click
      Msgbox(cm.SelectedText)
End Sub


Sub dzfrm_MenuClick
      Msgbox(dzfrm.MenuSelectedText)
End Sub