Kbase P98456: How to get and set a Crystal Report's Printer settings?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  06/12/2004 |
|
Status: Unverified
GOAL:
How to read and modify a Crystal Reports Printer settings?
FIX:
The following 4GL code demonstrates how to programmatically modify a Crystal Reports Printer settings at runtime. Specifically, it demonstrates how to get and set PaperSize, PaperOrientation, PaperSource, and PrinterDuplex for the report printer options. The code also demonstrates the use of the PrinterSetup method which provides a Windows standard printer setup window to allow the user to change the printer properties directly at runtime. Note that changing the Windows standard printer setup will not alter the report printer settings and vice-versa.
1. The following include file; 'CrystalReportsPrinterSettingsConstants.i'; contains the Crystal Reports constants for the properties used in the procedure.
/* The 'PaperSource' property supports these values: */
&GLOBAL-DEFINE crPRBinAuto 7
&GLOBAL-DEFINE crPRBinCassette 14
&GLOBAL-DEFINE crPRBinEnvelope 5
&GLOBAL-DEFINE crPRBinEnvManual 6
&GLOBAL-DEFINE crPRBinFormSource 15
&GLOBAL-DEFINE crPRBinLargeCapacity 11
&GLOBAL-DEFINE crPRBinLargeFmt 10
&GLOBAL-DEFINE crPRBinLower 2
&GLOBAL-DEFINE crPRBinManual 4
&GLOBAL-DEFINE crPRBinMiddle 3
&GLOBAL-DEFINE crPRBinSmallFmt 9
&GLOBAL-DEFINE crPRBinTractor 8
&GLOBAL-DEFINE crPRBinUpper 1
&GLOBAL-DEFINE DRIVE_UNKNOWN 0
/* The 'PaperSize' property supports these values: */
&GLOBAL-DEFINE crDefaultPaperSize 0 /* Read Only */
&GLOBAL-DEFINE crPaper10x14 16
&GLOBAL-DEFINE crPaper11x17 17
&GLOBAL-DEFINE crPaperA3 8
&GLOBAL-DEFINE crPaperA4 9
&GLOBAL-DEFINE crPaperA4Small 10
&GLOBAL-DEFINE crPaperA5 11
&GLOBAL-DEFINE crPaperB4 12
&GLOBAL-DEFINE crPaperB5 13
&GLOBAL-DEFINE crPaperCsheet 24
&GLOBAL-DEFINE crPaperDsheet 25
&GLOBAL-DEFINE crPaperEnvelope10 20
&GLOBAL-DEFINE crPaperEnvelope11 21
&GLOBAL-DEFINE crPaperEnvelope12 22
&GLOBAL-DEFINE crPaperEnvelope14 23
&GLOBAL-DEFINE crPaperEnvelope9 19
&GLOBAL-DEFINE crPaperEnvelopeB4 33
&GLOBAL-DEFINE crPaperEnvelopeB5 34
&GLOBAL-DEFINE crPaperEnvelopeB6 35
&GLOBAL-DEFINE crPaperEnvelopeC3 28
&GLOBAL-DEFINE crPaperEnvelopeC4 29
&GLOBAL-DEFINE crPaperEnvelopeC5 30
&GLOBAL-DEFINE crPaperEnvelopeC6 31
&GLOBAL-DEFINE crPaperEnvelopeC65 32
&GLOBAL-DEFINE crPaperEnvelopeDL 27
&GLOBAL-DEFINE crPaperEnvelopeItaly 36
&GLOBAL-DEFINE crPaperEnvelopeMonarch 37
&GLOBAL-DEFINE crPaperEnvelopePersonal 38
&GLOBAL-DEFINE crPaperEsheet 26
&GLOBAL-DEFINE crPaperExecutive 7
&GLOBAL-DEFINE crPaperFanfoldLegalGerman 41
&GLOBAL-DEFINE crPaperFanfoldStdGerman 40
&GLOBAL-DEFINE crPaperFanfoldUS 39
&GLOBAL-DEFINE crPaperFolio 14
&GLOBAL-DEFINE crPaperLedger 4
&GLOBAL-DEFINE crPaperLegal 5
&GLOBAL-DEFINE crPaperLetter 1
&GLOBAL-DEFINE crPaperLetterSmall 2
&GLOBAL-DEFINE crPaperNote 18
&GLOBAL-DEFINE crPaperQuarto 15
&GLOBAL-DEFINE crPaperStatement 6
&GLOBAL-DEFINE crPaperTabloid 3
/* The 'PrinterDuplex' property supports these values: */
&GLOBAL-DEFINE crPRDPDefault 0
&GLOBAL-DEFINE crPRDPHorizontal 3
&GLOBAL-DEFINE crPRDPSimplex 1
&GLOBAL-DEFINE crPRDPVertical 2
/* The 'PaperOrientation' property supports these values: */
&GLOBAL-DEFINE crDefaultPaperOrientation - 0
&GLOBAL-DEFINE crPortrait - 1
&GLOBAL-DEFINE crLandscape - 2
2. The following procedure; 'CrystalPrinterAttributes.p'; uses the above include file to exercise the various properties of a Crystal Report object printer settings and invokes the Crystal Report PrinterSetup method that allows user modification of the Crystal report's Printer options:
{CrystalReportsPrinterSettingsConstants.i}
DEF VAR vCRapplica.tion AS COM-HANDLE NO-UNDO.
DEF VAR vCRreport AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE iHwnd AS INTEGER NO-UNDO.
CREATE "CrystalRuntime.Application" vCRapplication.
CREATE "CrystalRuntime.Report" vCRreport.
/* Open the report */
vCRreport = vCRapplication:OpenReport("Customer.Rpt") NO-ERROR.
/* Get The handle of the parent Windows window */
iHwnd = CURRENT-WINDOW:HWND.
/* Message current printer settings */
MESSAGE
vCRreport:PaperOrientation
vCRreport:PaperSize
vCRreport:PaperSource
vCRreport:PrinterDuplex
VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* Modify the printer settings using Crystal Reports Printer Setup Dialog */
vCRreport:PrinterSetup(iHwnd).
/* Message the modified printer settings */
MESSAGE
vCRreport:PaperOrientation
vCRreport:PaperSize
vCRreport:PaperSource
vCRreport:PrinterDuplex
VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* Modify the printing options using 4GL */
ASSIGN
vCRreport:PaperSource = {&crPRBinAuto}
vCRreport:PaperSize = {&crDefaultPaperSize}
vCRreport:PrinterDuplex = {&crPRDPDefault}
vCRreport:PaperOrientation = {&crDefaultPaperOrientation}.
/* Message the modified printer settings */
MESSAGE
vCRreport:PaperOrientation
vCRreport:PaperSize
vCRreport:PaperSource
vCRreport:PrinterDuplex
VIEW-AS ALERT-BOX INFO BUTTONS OK..