![]() ![]() ![]() ![]() Gravitybox Schedule Primer
Page 144
1998-2004 Gravitybox Software LLC
oPrinterParameter.PrinterDeviceName = Printer.DeviceName
PrintFile = Schedule1.GoPrint(1, _
Schedule1.Rooms.Count, _
Schedule1.StartTime, _
DateAdd("h", Schedule1.DayLength, _
Schedule1.StartTime), _
oPrinterParameter)
Set oPrinterParameter = Nothing
End Function
Next we need to a property to the child form called Changed. This is a Boolean
property that will keep up with the changed state of the schedule. When true, it means
that the schedule needs to be saved to file. After loading and saving this property is set
to false, because there is nothing that has changed since the last save. In the
schedules events that signify change we will set this variable to true as in the following
code.
Private Sub Schedule1_AfterAdd(ByVal NewIndex As Long)
Changed = True
End Sub
The events that need this line of code include: AfterAdd, AfterCopy, AfterDelete,
AfterDragFromFile, AfterEdit, AfterEditNotes, AfterEditText, and AfterMove. If any one
of these events is raised the schedule will need to be saved.
If the user presses the child window close button, how will the schedule know to save?
In the Form_QueryUnload event we will add code to catch this situation.
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
If Changed Then
Select Case MsgBox("This schedule has been modified. Do you
wish to save?", vbYesNoCancel + vbQuestion, "Save?")
Case vbYes: Call SaveFile
Case vbNo: 'Do Nothing
Case vbCancel: Cancel = True
End Select
End If
End Sub
If the Changed variable is set we will prompt the user to save the form. The user may
then choose Yes to save and unload, No to not save and unload, or Cancel to not
save and cancel the unload of the window all together.
|