Navigation bar
  Home Print document Start Previous page
 147 of 234 
Next page End  

Gravitybox Schedule Primer
Page 145 
1998-2004 Gravitybox Software LLC
Now that the child form has been constructed we need a way to open these forms as
well as a container in which to contain them. So we need to build an MDI parent form.
We add one to our project and start by declaring the menus. Open the menu editor and
add a top-level menu. We will set the caption to “File” and name it “mnuFile”. Under this
menu will add the following menus: Open, Close, Save, Print, and 
Exit. This will provide us with the needed functionality to use this program.
The open menu item will prompt the user for a date and if the date has not been loaded
previously, it will load a child form and have it open the saved file. If the file does not
exist it will load a blank schedule, remember? The GetDate function is defined later; just
assume that it will return a date to open.
Private Sub mnuFileOpen_Click()
Dim F As frmChild
Dim dtDate As Date
  'Get a date from the user If valid then
  'open a child window and load this date
  If GetDate(dtDate) Then
    If IsDateLoaded(dtDate) Then
      Call MsgBox("This date is already loaded!", bExclamation)
    Else
      Set F = New frmChild
      Call F.OpenFile(dtDate)
      Call F.Show
      Call UpdateMenu
    End If
  End If
End Sub
The Close menu item will do nothing more than close the active form.
Private Sub mnuFileClose_Click()
  Unload Me.ActiveForm
  Call UpdateMenu
End Sub
The Save menu item will call the SaveFile method of the child form. Each child knows
how to save itself.
Private Sub mnuFileSave_Click()
  Call Me.ActiveForm.SaveFile
http://www.purepage.com