home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / crystal / extras / vbvbx / global.bas < prev    next >
Encoding:
BASIC Source File  |  1994-11-20  |  16.5 KB  |  467 lines

  1. '
  2. '               Visual Basic Declarations of CRPE.DLL
  3. '               =====================================
  4. '
  5. '       File:         GLOBAL.BAS
  6. '
  7. '       Author:       Crystal Computer Services, Inc.
  8. '       Date:         15 Apr 92
  9. '
  10. '       Purpose:      This file presents the API to the Crystal Reports
  11. '                     Print Engine DLL.
  12. '
  13. '       Language:     Visual Basic for Windows
  14. '
  15. '       Copyright (c) 1992-1994 Crystal Services
  16. '
  17. '       Revisions:
  18. '
  19. '          CCS  15 Apr 92  -  Original Development
  20. '          KYL  12 Jul 92  -  Modified Existing Declarations
  21. '                             Added Missing Declarations
  22. '          KYL  27 Aug 92  -  Converted to CRPE.DLL
  23. '          CRD  08 Feb 93  -  Added new calls for 2.0 and Global declares for samples
  24. '          CRD  25 Feb 93  -  Added new calls for 2.0 Pro
  25. '          RBC  23 Apr 93  -  Added more new calls, rearranged to match CRPE.H
  26. '          DVA  22 Dec 93  -  Added new calls for 3.0
  27. '          TW   15 Mar 94  -  3.0 call reorganization
  28. '
  29. '----------------------------------------------------------------
  30. 'This Application's Global Variables
  31. Global Jobnumber As Integer
  32. Global ReportName As String
  33. Global EngineOpened As Integer
  34. Global GetErrortext As String
  35. Global FileType As Integer
  36. Global FileName As String
  37.  
  38.  
  39. ' Open, print and close report (used when no changes needed to report)
  40. ' --------------------------------------------------------------------
  41.  
  42. Declare Function PEPrintReport Lib "CRPE.DLL" (ByVal RptName$, ByVal Printer%, ByVal Window%, ByVal Title$, ByVal Lft%, ByVal Top%, ByVal Wdth%, ByVal Height%, ByVal Style As Long, ByVal PWindow%) As Integer
  43.  
  44.  
  45. ' Open and close print engine
  46. ' ---------------------------
  47.  
  48. Declare Function peopenengine Lib "CRPE.DLL" () As Integer
  49.  
  50. Declare Sub PeCloseEngine Lib "CRPE.DLL" ()
  51.  
  52.  
  53. ' Get version info
  54. ' ----------------
  55.  
  56. Const PE_GV_DLL = 100      ' values for version parameter of PEGetVersion
  57. Const PE_GV_ENGINE = 200
  58.  
  59. Declare Function PEGetVersion Lib "CRPE.DLL" (ByVal version%) As Integer
  60.  
  61.  
  62. ' Open and close print job (i.e. report)
  63. ' --------------------------------------
  64.  
  65. Declare Function PEOpenPrintJob Lib "CRPE.DLL" (ByVal RptName$) As Integer
  66.  
  67. Declare Sub PEClosePrintJob Lib "CRPE.DLL" (ByVal PrintJob%)
  68.  
  69.  
  70. ' Start and cancel print job (i.e. print the report, usually after changing report)
  71. ' ---------------------------------------------------------------------------------
  72.  
  73. Declare Function PEStartPrintJob Lib "CRPE.DLL" (ByVal PrintJob%, ByVal WaitOrNot%) As Integer
  74.  
  75. Declare Sub PECancelPrintJob Lib "CRPE.DLL" (ByVal PrintJob%)
  76.  
  77.  
  78. ' Print job status
  79. ' ----------------
  80.  
  81. Declare Function PEIsPrintJobFinished Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  82.  
  83. Type PEJobInfo
  84.     StructSize As Integer  ' initialize to # of bytes in PEJobInfo
  85.  
  86.     NumRecordsRead As Long
  87.     NumRecordsSelected As Long
  88.     NumRecordsPrinted As Long
  89.  
  90.     DisplayPageN As Integer
  91.     LatestPageN As Integer
  92.     StartPageN As Integer
  93.  
  94.     PrintEnded As Integer
  95. End Type
  96.  
  97. Declare Function PEGetJobStatus Lib "CRPE.DLL" (ByVal PrintJob%, JobInfo As PEJobInfo) As Integer
  98.  
  99.  
  100. ' Print job error codes and messages
  101. ' ----------------------------------
  102.  
  103. Declare Function PeGetErrorCode Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  104.  
  105. Declare Function PEGetErrorText Lib "CRPE.DLL" (ByVal PrintJob%, TextHandle%, TextLength%) As Integer
  106.  
  107. Declare Function PEGetHandleString Lib "CRPE.DLL" (ByVal TextHandle%, ByVal Buffer$, ByVal BufferLength%) As Integer
  108.  
  109.  
  110. ' Setting the print date
  111. ' ----------------------
  112.  
  113. Declare Function PESetPrintDate Lib "CRPE.DLL" (ByVal PrintJob%, ByVal Date_Year%, ByVal Date_Month%, ByVal Date_Day%) As Integer
  114.  
  115.  
  116. ' Controlling formulas, selection formulas and group selection formulas
  117. ' ---------------------------------------------------------------------
  118.  
  119. Declare Function PEGetFormula Lib "CRPE.DLL" (ByVal PrintJob%, ByVal FormulaName$, TextHandle%, TextLength%) As Integer
  120.  
  121. Declare Function PESetFormula Lib "CRPE.DLL" (ByVal PrintJob%, ByVal FormulaName$, ByVal FormulaString$) As Integer
  122.  
  123. Declare Function PeGetSelectionFormula Lib "CRPE.DLL" (ByVal PrintJob%, TextHandle%, TextLength%) As Integer
  124.  
  125. Declare Function PESetSelectionFormula Lib "CRPE.DLL" (ByVal PrintJob%, ByVal FormulaString$) As Integer
  126.  
  127. Declare Function PEGetGroupSelectionFormula Lib "CRPE.DLL" (ByVal PrintJob%, TextHandle%, TextLength%) As Integer
  128.  
  129. Declare Function PESetGroupSelectionFormula Lib "CRPE.DLL" (ByVal PrintJob%, ByVal FormulaString$) As Integer
  130.  
  131.  
  132. ' Controlling group conditions (i.e. group breaks)
  133. ' ------------------------------------------------
  134.  
  135. Const PE_GC_ANYCHANGE = 0  ' values for the Condition parameter of PESetGroupCondition
  136.                            ' use PE_ANYCHANGE for all field types except Date and Boolean
  137.  
  138. Const PE_GC_DAILY = 0      ' use these constants for Date fields
  139. Const PE_GC_WEEKLY = 1
  140. Const PE_GC_BIWEEKLY = 2
  141. Const PE_GC_SEMIMONTHLY = 3
  142. Const PE_GC_MONTHLY = 4
  143. Const PE_GC_QUARTERLY = 5
  144. Const PE_GC_SEMIANNUALLY = 6
  145. Const PE_GC_ANNUALLY = 7
  146.  
  147. Const PE_GC_TOYES = 1      ' use these constants for Boolean fields
  148. Const PE_GC_TONO = 2
  149. Const PE_GC_EVERYYES = 3
  150. Const PE_GC_EVERYNO = 4
  151. Const PE_GC_NEXTISYES = 5
  152. Const PE_GC_NEXTISNO = 6
  153.  
  154. Declare Function PESetGroupCondition Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SectionCode%, ByVal ConditionField$, ByVal Condition%, ByVal SortDirection%) As Integer
  155.  
  156.  
  157. ' Controlling sort order and group sort order
  158. ' -------------------------------------------
  159.  
  160. Const PE_SF_MAXNAMELEN = 50  ' maximum length of a sort field name
  161.  
  162. Const PE_SF_DESC = 0         ' values for the Direction parameter
  163. Const PE_SF_ASC = 1
  164.  
  165. Declare Function PEGetNSortFields Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  166.  
  167. Declare Function PEGetNthSortField Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SortNumber%, NameHandle%, NameLength%, Direction%) As Integer
  168.  
  169. Declare Function PESetNthSortField Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SortNumber%, ByVal SortFieldName$, ByVal Direction%) As Integer
  170.  
  171. Declare Function PEDeleteNthSortField Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SortFieldN%) As Integer
  172.  
  173. Declare Function PEGetNGroupSortFields Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  174.  
  175. Declare Function PEGetNthGroupSortField Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SortFieldN%, NameHandle%, NameLength%, Direction%) As Integer
  176.  
  177. Declare Function PESetNthGroupSortField Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SortFieldN%, ByVal SortGroupName$, ByVal Direction%) As Integer
  178.  
  179. Declare Function PEDeleteNthGroupSortField Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SortFieldN%) As Integer
  180.  
  181.  
  182. ' Controlling databases (see CRPE.H for more comments)
  183. ' ----------------------------------------------------
  184.  
  185. Declare Function PEGetNTables Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  186.  
  187. Const PE_DLL_NAME_LEN = 64
  188. Const PE_FULL_NAME_LEN = 256
  189.  
  190. Type PETableType
  191.     StructSize As Integer   ' initialize to # bytes in PETableType
  192.  
  193.     DLLName As String * PE_DLL_NAME_LEN
  194.     DescriptiveName  As String * PE_FULL_NAME_LEN
  195.  
  196.     DBType As Integer
  197. End Type
  198.  
  199. Global Const PE_DT_STANDARD = 1  ' values for DBType
  200. Global Const PE_DT_SQL = 2
  201.  
  202. Declare Function PEGetNthTableType Lib "CRPE.DLL" (ByVal PrintJob%, ByVal TableN%, TableType As PETableType) As Integer
  203.  
  204. Const PE_LONGPTR_LEN = 4
  205. Const PE_SESS_USERID_LEN = 128
  206. Const PE_SESS_PASSWORD_LEN = 128
  207.  
  208. Type PESessionInfo
  209.     StructSize As Integer   'initialize to # bytes in PESessionInfo
  210.  
  211.     UserID As String * PE_SESS_PASSWORD_LEN
  212.     Password As String * PE_SESS_PASSWORD_LEN
  213.  
  214.     SessionHandle As Long
  215. End Type
  216.  
  217. Declare Function PEGetNthTableSessionInfo Lib "CRPE.DLL" (ByVal PrintJob%, ByVal TableN%, SessionInfo As PESessionInfo) As Integer
  218.  
  219. Declare Function PESetNthTableSessionInfo Lib "CRPE.DLL" (ByVal PrintJob%, ByVal TableN%, SessionInfo As PESessionInfo, ByVal PropagateAcrossTables%) As Integer
  220.  
  221. Const PE_SERVERNAME_LEN = 128
  222. Const PE_DATABASENAME_LEN = 128
  223. Const PE_USERID_LEN = 128
  224. Const PE_PASSWORD_LEN = 128
  225.  
  226. Type PELogOnInfo
  227.     StructSize As Integer   ' initialize to # bytes in PELogOnInfo
  228.  
  229.     ' For any of the following values an empty string ("") means to use
  230.     ' the value already set in the report.  To override a value in the
  231.     ' report use a non-empty string (e.g. "Server A").  All strings are
  232.     ' null-terminated.
  233.  
  234.     ' For Netware SQL, pass the dictionary path name in ServerName and
  235.     ' data path name in DatabaseName.
  236.  
  237.     ServerName As String * PE_SERVERNAME_LEN
  238.     DatabaseName  As String * PE_DATABASENAME_LEN
  239.     UserID As String * PE_USERID_LEN
  240.  
  241.     ' Password is undefined when getting information from report.
  242.  
  243.     Password  As String * PE_PASSWORD_LEN
  244. End Type
  245.  
  246. Declare Function PEGetNthTableLogOnInfo Lib "CRPE.Dll" (ByVal PrintJob%, ByVal TableN%, LogOnInfo As PELogOnInfo) As Integer
  247. Declare Function PESetNthTableLogOnInfo Lib "CRPE.Dll" (ByVal PrintJob%, ByVal TableN%, LogOnInfo As PELogOnInfo, ByVal Propagate%) As Integer
  248.  
  249. Const PE_TABLE_LOCATION_LEN = 256
  250.  
  251. Type PETableLocation
  252.     StructSize As Integer   ' initialize to # bytes in PETableLocation
  253.  
  254.     ' String is null-terminated.
  255.     Location  As String * PE_TABLE_LOCATION_LEN
  256. End Type
  257.  
  258. Declare Function PEGetNthTableLocation Lib "CRPE.Dll" (ByVal PrintJob%, ByVal TableN%, Location As PETableLocation) As Integer
  259. Declare Function PESetNthTableLocation Lib "CRPE.Dll" (ByVal PrintJob%, ByVal TableN%, Location As PETableLocation) As Integer
  260.  
  261. Declare Function PETestNthTableConnectivity Lib "CRPE.Dll" (ByVal PrintJob%, ByVal TableN%) As Integer
  262.  
  263. Declare Function PELogOnServer Lib "CRPE.Dll" (ByVal DLLName$, LogOnInfo As PELogOnInfo) As Integer
  264. Declare Function PELogOffServer Lib "CRPE.Dll" (ByVal DLLName$, LogOnInfo As PELogOnInfo) As Integer
  265.  
  266. Declare Function PEGetNFiles Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  267. Declare Function PEGetNthFileName Lib "CRPE.DLL" (ByVal PrintJob%, ByVal FileN%, NameHandle%, NameLength%) As Integer
  268. Declare Function PESetNthFileName Lib "CRPE.DLL" (ByVal PrintJob%, ByVal FileN%, ByVal Set_Name$) As Integer
  269.  
  270.  
  271. ' Overriding SQL query in report
  272. ' ------------------------------
  273.  
  274. Declare Function PEGetSQLQuery Lib "CRPE.DLL" (ByVal PrintJob%, TextHandle%, TextLength%) As Integer
  275.  
  276. Declare Function PESetSQLQuery Lib "CRPE.DLL" (ByVal PrintJob%, ByVal QueryString$) As Integer
  277.  
  278.  
  279. ' Refreshing saved data
  280. ' ---------------------
  281.  
  282. Declare Function PESetRefreshData Lib "CRPE.DLL" (ByVal PrintJob%, ByVal RefreshData%) As Integer
  283.  
  284.  
  285. ' Report title
  286. ' ------------
  287.  
  288. Declare Function PEGetReportTitle Lib "CRPE.DLL" (ByVal PrintJob%, TitleHandle%, TitleLength%) As Integer
  289. Declare Function PESetReportTitle Lib "CRPE.DLL" (ByVal PrintJob%, ByVal Title$) As Integer
  290.  
  291.  
  292. ' Controlling printed pages
  293. ' -------------------------
  294.  
  295. Declare Function PEShowNextPage Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  296.  
  297. Declare Function PEShowFirstPage Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  298.  
  299. Declare Function PEShowPreviousPage Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  300.  
  301. Declare Function PEShowLastPage Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  302.  
  303. Declare Function PEShowPrintControls Lib "CRPE.DLL" (ByVal PrintJob%, ByVal ShowPrintControls%) As Integer
  304.  
  305.  
  306. ' Changing printer selection
  307. ' --------------------------
  308.  
  309. Declare Function PESelectPrinter Lib "CRPE.DLL" (ByVal PrintJob%, ByVal PrinterDriver$, ByVal PrinterName$, ByVal PortName$, ByVal DevMode As Long) As Integer
  310.  
  311.  
  312. ' Controlling print to printer
  313. ' ----------------------------
  314.  
  315. Declare Function PEOutputToDefaultPrinter Lib "CRPE.DLL" (ByVal PrintJob%, ByVal NCopies%) As Integer
  316.  
  317. Declare Function PEOutPutToPrinter Lib "CRPE.DLL" (ByVal PrintJob%, ByVal NCopies%) As Integer
  318.  
  319. Declare Function PESetNDetailCopies Lib "CRPE.DLL" (ByVal PrintJob%, ByVal nDetailCopies%) As Integer
  320.  
  321. Const PE_MAXPAGEN = 65535
  322.  
  323. Type PEPrintOptions
  324.     StructSize As Integer   ' initialize to # bytes in PEPrintOptions
  325.  
  326.     ' page and copy numbers are 1-origin
  327.     ' use 0 to preserve the existing settings
  328.     StartPageN As Integer
  329.     stopPageN As Integer
  330.  
  331.     nReportCopies As Integer
  332.     collation As Integer
  333. End Type
  334.  
  335. ' values for collation
  336. Const PE_UNCOLLATED = 0
  337. Const PE_COLLATED = 1
  338. Const PE_DEFAULTCOLLATION = 2
  339.  
  340. Declare Function PESetPrintOptions Lib "CRPE.Dll" (ByVal PrintJob%, Options As PEPrintOptions) As Integer
  341.  
  342.  
  343. ' Controlling print to window
  344. ' ---------------------------
  345.  
  346. Declare Function PeOutPutToWindow Lib "CRPE.DLL" (ByVal PrintJob%, ByVal Title$, ByVal Lft%, ByVal Top%, ByVal Wdth%, ByVal Height%, ByVal Style As Long, ByVal PWindow%) As Integer
  347.  
  348. Declare Function PEGetWindowHandle Lib "CRPE.DLL" (ByVal PrintJob%) As Integer
  349.  
  350. Declare Function PEPrintWindow Lib "CRPE.Dll" (ByVal PrintJob%, ByVal WaitNoWait%) As Integer
  351.  
  352. Declare Sub PECloseWindow Lib "CRPE.DLL" (ByVal PrintJob%)
  353.  
  354.  
  355. ' Controlling print to file and export
  356. ' ------------------------------------
  357.  
  358. ' Types for the Options parameter of PEOutputToFile
  359. ' Use for all types except PE_FT_CHARSEPARATED
  360. Type PEPrintFileOptions
  361.     StructSize As Integer   ' initialize to # of bytes in PEPrintFileOptions
  362.  
  363.     UseReportNumberFmt As Integer
  364.     UseReportDateFormat As Integer
  365. End Type
  366.  
  367. Const PE_FIELDDELIMLEN = 17
  368.  
  369. ' Use for PE_FT_CHARSEPARATED
  370. Type PECharSepFileOptions
  371.     StructSize As Integer   ' initialize to # of bytes in PECharSepFileOptions
  372.  
  373.     UseReportNumberFmt As Integer
  374.     UseReportDateFormat As Integer
  375.     StringDelimiter As String * 1
  376.     FieldDelimiter As String * PE_FIELDDELIMLEN
  377. End Type
  378.  
  379. ' values for FileType
  380. Const PE_FT_RECORD = 0
  381. Const PE_FT_TABSEPARATED = 1
  382. Const PE_FT_TEXT = 2
  383. Const PE_FT_DIF = 3
  384. Const PE_FT_CSV = 4
  385. Const PE_FT_CHARSEPARATED = 5
  386. Const PE_FT_TABFORMATTED = 6
  387.  
  388. Declare Function PEOutPutToFile Lib "CRPE.DLL" (ByVal PrintJob%, ByVal OutputFilePath$, ByVal FileType%, Options As Any) As Integer
  389.  
  390. Type PEExportOptions
  391.     StructSize As Integer   'initialize to # bytes in PEExportOptions
  392.  
  393.     FormatDLLName As String * PE_DLL_NAME_LEN
  394.     FormatType As Long
  395.     FormatOptions As Long
  396.     DestinationDLLName As String * PE_DLL_NAME_LEN
  397.     DestinationType As Long
  398.     DestinationOptions As Long
  399.     NFormatOptionsBytes As Integer
  400.     NDestinationOptionsBytes As Integer
  401. End Type
  402.  
  403. Declare Function PEGetExportOptions Lib "CRPE.DLL" (ByVal PrintJob%, ExportOptions As PEExportOptions) As Integer
  404.  
  405. Declare Function PEExportTo Lib "CRPE.DLL" (ByVal PrintJob%, ExportOptions As PEExportOptions) As Integer
  406.  
  407.  
  408. ' Setting page margins
  409. ' --------------------
  410.  
  411. Declare Function PESetMargins Lib "CRPE.DLL" (ByVal PrintJob%, ByVal LeftMargin%, ByVal RightMargin%, ByVal TopMargin%, ByVal BottomMargin%) As Integer
  412.  
  413.  
  414. ' Setting section height and format
  415. ' ---------------------------------
  416.  
  417. ' values for SectionCode parameter
  418. Const PE_ALLSECTIONS = 0
  419. Const PE_HEADERSECTION = 2000
  420. Const PE_GROUPHEADER = 3000       ' outer group header is 3000, next is 3001, etc.
  421. Const PE_DETAILSECTION = 4000
  422. Const PE_GROUPFOOTER = 5000       ' outer group footer is 5000, next is 5001, etc.
  423. Const PE_GRANDTOTALSECTION = 6000
  424. Const PE_FOOTERSECTION = 7000
  425.  
  426. ' MinimumHeight is in twips - 1440 twips to the inch
  427. Declare Function PESetMinimumSectionHeight Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SectionCode%, ByVal MinimumHeight%) As Integer
  428.  
  429. Type PESectionOptions
  430.     StructSize As Integer   ' initialize to # bytes in PESectionOptions
  431.  
  432.     ' use 0 to turn off, 1 to turn on and -1 to preserve each attribute
  433.     Visible As Integer
  434.     NewPageBefore As Integer
  435.     NewPageAfter As Integer
  436.     KeepTogether As Integer
  437.     SuppressBlankLines As Integer
  438.     ResetPageNAfter As Integer
  439.     PrintAtBottomOfPage As Integer
  440. End Type
  441.  
  442. Declare Function PESetSectionFormat Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SectionCode%, Options As PESectionOptions) As Integer
  443.  
  444.  
  445. ' Setting line height
  446. ' -------------------
  447.  
  448. ' use PE_ALLLINES to set the height of all lines in a section
  449. Const PE_ALLLINES = -1
  450.  
  451. ' Height and Ascent are in twips
  452. Declare Function PESetLineHeight Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SectionCode%, ByVal LineN%, ByVal Height%, ByVal Ascent%) As Integer
  453.  
  454.  
  455. ' Setting font info
  456. ' -----------------
  457.  
  458. ' values for ScopeCode - may be ORed together
  459. Const PE_FIELDS = 1
  460. Const PE_TEXT = 2
  461.  
  462. ' use for isItalic, isUnderlined, or isStruckOut to preserve the existing value
  463. Const PE_UNCHANGED = -1
  464.  
  465. Declare Function PESetFont Lib "CRPE.DLL" (ByVal PrintJob%, ByVal SectionCode%, ByVal ScopeCode%, ByVal FaceName$, ByVal FontFamily%, ByVal FontPitch%, ByVal CharSet%, ByVal PointSize%, ByVal isItalic%, ByVal isUnderlined%, ByVal isStruckOut%, ByVal Weight%)
  466.  
  467.