home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / crwdemo / export.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-11-01  |  5.8 KB  |  173 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2715
  5.    ClientLeft      =   1020
  6.    ClientTop       =   1425
  7.    ClientWidth     =   5640
  8.    Height          =   3120
  9.    Left            =   960
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2715
  12.    ScaleWidth      =   5640
  13.    Top             =   1080
  14.    Width           =   5760
  15.    Begin CommandButton Command5 
  16.       Caption         =   "Start"
  17.       Height          =   495
  18.       Left            =   4200
  19.       TabIndex        =   4
  20.       Top             =   120
  21.       Width           =   1215
  22.    End
  23.    Begin CommandButton Command4 
  24.       Caption         =   "Export To"
  25.       Height          =   495
  26.       Left            =   2160
  27.       TabIndex        =   3
  28.       Top             =   720
  29.       Width           =   1815
  30.    End
  31.    Begin CommandButton Command3 
  32.       Caption         =   "Get Export Options"
  33.       Height          =   495
  34.       Left            =   2160
  35.       TabIndex        =   2
  36.       Top             =   120
  37.       Width           =   1815
  38.    End
  39.    Begin CommandButton Command2 
  40.       Caption         =   "Close Job"
  41.       Height          =   495
  42.       Left            =   120
  43.       TabIndex        =   1
  44.       Top             =   720
  45.       Width           =   1215
  46.    End
  47.    Begin CommonDialog CMDialog1 
  48.       DialogTitle     =   "Open Report"
  49.       Filter          =   "Crystal Reports|*.rpt"
  50.       Flags           =   4096
  51.       Left            =   1440
  52.       Top             =   120
  53.    End
  54.    Begin CommandButton Command1 
  55.       Caption         =   "Open Job"
  56.       Height          =   495
  57.       Left            =   120
  58.       TabIndex        =   0
  59.       Top             =   120
  60.       Width           =   1215
  61.    End
  62.    Begin Label Label1 
  63.       Caption         =   "To use this app:                                                                        1) open a job                                                                      2a) choose Get Export Options && Export To                         or                                                                                         2b) just choose Export To                                                    3) Start the job"
  64.       Height          =   1215
  65.       Left            =   120
  66.       TabIndex        =   5
  67.       Top             =   1320
  68.       Width           =   5295
  69.       WordWrap        =   -1  'True
  70.    End
  71. Dim OpenResult As Integer
  72. Dim JobHandle As Integer
  73. Dim ExportOptions As PEExportOptions
  74. Dim ExportOptionsValid As Integer
  75. Sub Command1_Click ()
  76.     If JobHandle <> 0 Then
  77.         MsgBox "Job already open"
  78.         Exit Sub
  79.     End If
  80.     CMDialog1.Action = 1
  81.     If CMDialog1.Filename <> "" Then
  82.         JobHandle = PEOpenPrintJob(CMDialog1.Filename)
  83.         If JobHandle = 0 Then
  84.             MsgBox "Can't open job - error " & PEGetErrorCode(0)
  85.         End If
  86.     End If
  87. End Sub
  88. Sub Command2_Click ()
  89.     If JobHandle = 0 Then
  90.         MsgBox "Job not open"
  91.         Exit Sub
  92.     End If
  93.     PEClosePrintJob (JobHandle)
  94.     JobHandle = 0
  95.     Call InitExportOptions
  96. End Sub
  97. Sub Command3_Click ()
  98.     If JobHandle = 0 Then
  99.         MsgBox "Job not open"
  100.         Exit Sub
  101.     End If
  102.     If ExportOptionsValid = 0 Then
  103.         Call InitExportOptions
  104.     End If
  105.     ' PEGetExportOptions gets complete information about format and
  106.     ' destination for the export
  107.     ' The ExportOptions must be passed to PEExportTo before calling PEStartPrintJob
  108.     ExportOptionsValid = PEGetExportOptions(JobHandle, ExportOptions)
  109. End Sub
  110. Sub Command4_Click ()
  111.     If JobHandle = 0 Then
  112.         MsgBox "Job not open"
  113.         Exit Sub
  114.     End If
  115.     If ExportOptionsValid = 0 Then
  116.         Call InitExportOptions
  117.     End If
  118.     ' Whenever you call PEExportTo, you must ensure that the format
  119.     ' and dll names have been filled in
  120.     ' You can do this by assigning specific names (as InitExportOptions does)
  121.     ' or by calling PEGetExportOptions
  122.     ' If the ExportOptions structure doesn't contain all information needed
  123.     ' by a format or destination dll, it will ask for the information
  124.     ' when you call PEStartPrintJob
  125.     ' An ExportOptions structure filled in by PEGetExportOptions always has
  126.     ' all the information needed by both dll's
  127.     ExportOptionsValid = PEExportTo(JobHandle, ExportOptions)
  128.     If ExportOptionsValid = 0 Then
  129.         MsgBox "PEExportTo failed - error code: " & PEGetErrorCode(JobHandle)
  130.     End If
  131. End Sub
  132. Sub Command5_Click ()
  133.     If JobHandle = 0 Then
  134.         MsgBox "Job not open"
  135.         Exit Sub
  136.     End If
  137.     If ExportOptionsValid = 0 Then
  138.         MsgBox "Cannot print - no export options"
  139.         Exit Sub
  140.     End If
  141.     Dim success As Integer
  142.     success = PEStartPrintJob(JobHandle, 1)
  143.     If success <> 1 Then
  144.         MsgBox "Exporting failed - error code: " & PEGetErrorCode(JobHandle)
  145.     End If
  146. End Sub
  147. Sub Form_Load ()
  148.     JobHandle = 0
  149.     Call InitExportOptions
  150.     OpenResult = PEOpenEngine()
  151.     If OpenResult = 0 Then
  152.         MsgBox "PEOpenEngine returned " & OpenResult & " - error code " & PEGetErrorCode(0)
  153.     End If
  154. End Sub
  155. Sub Form_Unload (Cancel As Integer)
  156.     If OpenResult <> 0 Then
  157.         Call PECloseEngine
  158.     End If
  159.     JobHandle = 0
  160. End Sub
  161. Sub InitExportOptions ()
  162.     ExportOptions.StructSize = Len(ExportOptions)
  163.     ExportOptions.FormatDLLName = "uxftext" + Chr$(0)
  164.     ExportOptions.FormatType = 0
  165.     ExportOptions.FormatOptions = 0
  166.     ExportOptions.DestinationDLLName = "uxddisk" + Chr$(0)
  167.     ExportOptions.DestinationType = 0
  168.     ExportOptions.DestinationOptions = 0
  169.     ExportOptions.NFormatOptionsBytes = 0
  170.     ExportOptions.NDestinationOptionsBytes = 0
  171.     ExportOptionsValid = 0
  172. End Sub
  173.