home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / crystal / extras / crpedemo / printfrm.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-12-15  |  8.5 KB  |  244 lines

  1. VERSION 2.00
  2. Begin Form PrintFrm 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Print To Printer"
  5.    ClientHeight    =   3105
  6.    ClientLeft      =   2355
  7.    ClientTop       =   2700
  8.    ClientWidth     =   5430
  9.    Height          =   3510
  10.    Left            =   2295
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   3105
  15.    ScaleWidth      =   5430
  16.    Top             =   2355
  17.    Width           =   5550
  18.    Begin CommandButton Command1 
  19.       Caption         =   "Select Printer"
  20.       Height          =   405
  21.       Left            =   600
  22.       TabIndex        =   0
  23.       Top             =   2520
  24.       Width           =   1335
  25.    End
  26.    Begin CommandButton Command2 
  27.       Caption         =   "Print"
  28.       Default         =   -1  'True
  29.       Height          =   405
  30.       Left            =   2160
  31.       TabIndex        =   1
  32.       Top             =   2520
  33.       Width           =   1215
  34.    End
  35.    Begin CommandButton Command3 
  36.       Cancel          =   -1  'True
  37.       Caption         =   "Cancel"
  38.       Height          =   405
  39.       Left            =   3600
  40.       TabIndex        =   2
  41.       Top             =   2520
  42.       Width           =   1215
  43.    End
  44.    Begin SSFrame Frame3D1 
  45.       Font3D          =   0  'None
  46.       Height          =   2295
  47.       Left            =   150
  48.       TabIndex        =   6
  49.       Top             =   90
  50.       Width           =   5175
  51.       Begin TextBox NDetailCopies 
  52.          Height          =   285
  53.          Left            =   2400
  54.          TabIndex        =   3
  55.          Top             =   795
  56.          Width           =   615
  57.       End
  58.       Begin TextBox Copies 
  59.          Height          =   285
  60.          Left            =   2400
  61.          TabIndex        =   4
  62.          Top             =   1275
  63.          Width           =   615
  64.       End
  65.       Begin TextBox StartPage 
  66.          Height          =   285
  67.          Left            =   4440
  68.          TabIndex        =   5
  69.          Top             =   795
  70.          Width           =   615
  71.       End
  72.       Begin TextBox EndPage 
  73.          Height          =   285
  74.          Left            =   4440
  75.          TabIndex        =   14
  76.          Top             =   1275
  77.          Width           =   615
  78.       End
  79.       Begin SSCheck SavedData 
  80.          Caption         =   "Use Saved Data"
  81.          Font3D          =   0  'None
  82.          Height          =   495
  83.          Left            =   120
  84.          TabIndex        =   13
  85.          Top             =   1680
  86.          Width           =   1815
  87.       End
  88.       Begin Label Label1 
  89.          BackColor       =   &H00C0C0C0&
  90.          Caption         =   "Selected Printer:"
  91.          Height          =   255
  92.          Left            =   120
  93.          TabIndex        =   7
  94.          Top             =   360
  95.          Width           =   1455
  96.       End
  97.       Begin Label SelectedPrinter 
  98.          BackColor       =   &H00C0C0C0&
  99.          Height          =   255
  100.          Left            =   1680
  101.          TabIndex        =   8
  102.          Top             =   360
  103.          Width           =   3375
  104.       End
  105.       Begin Label Label3 
  106.          BackColor       =   &H00C0C0C0&
  107.          Caption         =   "Number of Detail Copies:"
  108.          Height          =   255
  109.          Left            =   120
  110.          TabIndex        =   9
  111.          Top             =   840
  112.          Width           =   2175
  113.       End
  114.       Begin Label Label4 
  115.          BackColor       =   &H00C0C0C0&
  116.          Caption         =   "Number of Report Copies:"
  117.          Height          =   255
  118.          Left            =   120
  119.          TabIndex        =   10
  120.          Top             =   1320
  121.          Width           =   2295
  122.       End
  123.       Begin Label Label5 
  124.          BackColor       =   &H00C0C0C0&
  125.          Caption         =   "Starting Page:"
  126.          Height          =   255
  127.          Left            =   3120
  128.          TabIndex        =   11
  129.          Top             =   840
  130.          Width           =   1335
  131.       End
  132.       Begin Label Label6 
  133.          BackColor       =   &H00C0C0C0&
  134.          Caption         =   "Ending Page:"
  135.          Height          =   255
  136.          Left            =   3120
  137.          TabIndex        =   12
  138.          Top             =   1320
  139.          Width           =   1215
  140.       End
  141.    End
  142. Sub Command1_Click ()
  143. SelectPrt.Show 1
  144. End Sub
  145. Sub Command2_Click ()
  146.     Dim options As PEPrintOptions
  147.     If PESetNDetailCopies(JobNum, Val(NDetailCopies.Text)) = False Then
  148.         RCode = GetErrorString(JobNum)
  149.         MsgBox "PESetNDetailCopies Error #: " + Str(ErrorCode) + " - " + RCode
  150.         Exit Sub
  151.     End If
  152.     options.StructSize = Len(options)
  153.     options.NReportCopies = Val(Copies.Text)
  154.     options.StartPageN = Val(StartPage.Text)
  155.     options.stopPageN = Val(EndPage.Text)
  156.     If PESetPrintOptions(JobNum, options) = False Then
  157.         RCode = GetErrorString(JobNum)
  158.         MsgBox "PESetPrintOptions Error #: " + Str(ErrorCode) + " - " + RCode
  159.         Exit Sub
  160.     End If
  161.     If PEOutputToPrinter(JobNum, Val(Copies.Text)) = False Then
  162.         RCode = GetErrorString(JobNum)
  163.         MsgBox "PEOutputToPrinter Error #: " + Str(ErrorCode) + " - " + RCode
  164.         Exit Sub
  165.     End If
  166.     If SavedData.Enabled = True And SavedData.Value = False Then
  167.         If PEDiscardSavedData(JobNum) = False Then
  168.             RCode = GetErrorString(JobNum)
  169.             MsgBox "PEStartPrintJob Error #: " + Str(ErrorCode) + " - " + RCode
  170.             Exit Sub
  171.         End If
  172.     End If
  173.      FreeRes = FreeResourcesAreAbove(20)
  174.      If FreeRes = False Then
  175.        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."
  176.        Exit Sub
  177.      End If
  178.     If PEStartPrintJob(JobNum, True) = False Then
  179.         RCode = GetErrorString(JobNum)
  180.         MsgBox "PEStartPrintJob Error #: " + Str(ErrorCode) + " - " + RCode
  181.         Exit Sub
  182.     Else
  183.       Main!StatusBar.Caption = "Printing to printer successful"
  184.     End If
  185. End Sub
  186. Sub Command3_Click ()
  187. Unload Me
  188. End Sub
  189. Sub Form_Load ()
  190.     Dim DriverHandle%, DriverLength%, PrinterHandle%, PrinterLength%, PortHandle%, PortLength%
  191.     Dim DevMode As Long
  192.     Dim PrinterDriver$, PrinterName$, PortName$
  193.     Dim DetailCopies%, ReportCopies%
  194.     Dim options As PEPrintOptions
  195.     Dim UseSavedData%
  196.     SelectedPrinter.Caption = "Use Default Printer"
  197.     If PEGetSelectedPrinter(JobNum, DriverHandle, DriverLength, PrinterHandle, PrinterLength, PortHandle, PortLength, DevMode) = False Then
  198.       RCode = GetErrorString(JobNum)
  199.       MsgBox "PEGetSelectedPrinter Error #: " + Str(ErrorCode) + " - " + RCode
  200.       Exit Sub
  201.     End If
  202.     If (DriverHandle <> 0) Then
  203.         PrinterDriver = String$(DriverLength, " ")
  204.         PrinterName = String$(PrinterLength, " ")
  205.         PortName = String$(PortLength, " ")
  206.         If PEGetHandleString(DriverHandle, PrinterDriver, DriverLength) = False Or PEGetHandleString(PrinterHandle, PrinterName, PrinterLength) = False Or PEGetHandleString(PortHandle, PortName, PortLength) = False Then
  207.           RCode = GetErrorString(JobNum)
  208.           MsgBox "PEGetSelectedPrinter Error #: " + Str(ErrorCode) + " - " + RCode
  209.           Exit Sub
  210.         End If
  211.         
  212.         SelectedPrinter.Caption = Left$(PrinterName, Len(PrinterName) - 1) & " on " & Left$(PortName, Len(PortName) - 1)
  213.     Else
  214.         SelectedPrinter.Caption = "Use Default Printer"
  215.     End If
  216.     If PEGetNDetailCopies(JobNum, DetailCopies) = False Then
  217.         RCode = GetErrorString(JobNum)
  218.         MsgBox "PEGetNDetailCopies Error #: " + Str(ErrorCode) + " - " + RCode
  219.         Exit Sub
  220.     End If
  221.     NDetailCopies.Text = DetailCopies
  222.     options.StructSize = Len(options)
  223.     If PEGetPrintOptions(JobNum, options) = False Then
  224.         RCode = GetErrorString(JobNum)
  225.         MsgBox "PEGetPrintOptions Error #: " + Str(ErrorCode) + " - " + RCode
  226.         Exit Sub
  227.     End If
  228.     Copies.Text = options.NReportCopies
  229.     StartPage.Text = ""
  230.     EndPage.Text = ""
  231.     If PEHasSavedData(JobNum, UseSavedData) = False Then
  232.         RCode = GetErrorString(JobNum)
  233.         MsgBox "PEHasSavedData Error #: " + Str(ErrorCode) + " - " + RCode
  234.         Exit Sub
  235.     End If
  236.     If UseSavedData = 1 Then
  237.         SavedData.Enabled = True
  238.         SavedData.Value = True
  239.     Else
  240.         SavedData.Enabled = False
  241.         SavedData.Value = False
  242.     End If
  243. End Sub
  244.