'Dimension a new child form for use with the Crystal Reports
'Print Window. See the VBXDEMO.TXT for more information
Dim C As New Child
'Turn Print Window controls either on or off based on
'value in 3D Check box.
If ShowControls.Value = False Then
Main.Report1.WindowControls = 0
'If the user does not want print controls then the
'following command buttons are displayed. They are
'page scrolling keys which allow you scroll from page to page
Main.Command3D17.Visible = True
Main.Panel3D1.Visible = True
Else
Main.Report1.WindowControls = 1
Main.Command3D17.Visible = False
Main.Panel3D1.Visible = False
End If
'Use the data saved in the report or discard it.
If SavedData.Enabled = True Then
Main.Report1.DiscardSavedData = 0
Else
Main.Report1.DiscardSavedData = 1
End If
'Set number of details copies to be printed. The default is
'set to 1
Main.Report1.DetailCopies = NDetailCopies.Text
'Check to see if the resources are above 20%. If they are then
'proceed with report printing. If not then ask user to close
'down a few applications and try again.
FreeRes = FreeResourcesAreAbove(20)
If FreeRes = False Then
MsgBox "Your System Resources are below 20% Free, the job cannot be started! Please exit CRPEDemo, close some of your other Windows applications and try again."
Exit Sub
End If
'Set mouse to an Hour glass
Screen.MousePointer = 11
'Set the Title of the MDI Child frame window.
C.Caption = "MDIChild-VBXDemo"
'Set the Crystal print window to be a child of the MDI child
'frame window.
Main.Report1.WindowParentHandle = C.hWnd
'Set the destination to Window(0)
Main.Report1.Destination = 0
'unload WinFRM before print window appears
Unload Me
'Print report to window. If this fails then retrieve the error
'number and error string and display in a message box. If the call
'is successful then display the appropriate message in the status
'bar caption. Notice that the PrintReport property was used
'so that a Result% was return inorder to do proper error checking
Main.Arrange Cascade
If Main.Report1.PrintReport <> 0 Then
Unload C
Screen.MousePointer = 0
MsgBox "Printing the Report to Window has caused Error#: " & Main.Report1.LastErrorNumber & " - " & Main.Report1.LastErrorString
Exit Sub
Else
Main!StatusBar.Caption = "Preview to window Successful."