DFPrintSetupDialog - cWinReport2
Invokes the the Printer Setup Dialog allowing the user to select a printer
Type: Function
Return Data Type: Boolean
Syntax
Function DFPrintSetupDialog Returns Boolean
Call Example
Get DFPrintSetupDialog to BooleanVariable
Description
DFPrintSetupDialog invokes the printer setup dialog. The dialog allows you to select a printer and printer characteristics such as paper size, paper bin, report orientation, etc.
Object oSetupButton is a Button
Set Label to "Printer Setup"
Set Location to 7 120
Procedure OnClick
Boolean bOk
Get DFPrintSetupDialog of oOrders to bOk
End_Procedure
End_Object // oSetupButton
The return value indicates if the dialog page is OKed (True) or canceled (False). This can be useful if you are printing directly to the printer and you need to invoke the print setup dialog before the report is run. In such a case, canceling the dialog should cancel the report job.
Object oPrintButton is a Button
Set Label to "Print to Printer"
Set Location to 7 120
Procedure OnClick
Boolean bOk
Get DFPrintSetupDialog of oOrders to bOk // if bOk=False, cancel
If bOk Begin
Send DFPrintDoc // print directly to the printer
End
End_Procedure
End_Object // oSetupButton
The print setup dialog can fail for reasons other than the user canceling it. In that case, you could call the CommDlgExtendedError Windows API function. This should return a more specific error code pertaining to the particular error that caused the dialog selection to fail. Refer to MSDN documentation for information about these values.
Object oPrintButton is a Button
Set Label to "Print to Printer"
Set Location to 7 120
Procedure OnClick
Boolean bSetupOk
Integer iResult
Get DFPrintSetupDialog of oReport to bSetupOk
If (not(bSetupOk)) Begin
Move (CommDlgExtendedError()) to iResult
If (iResult = 0) begin
// a result of 0 means that the user cancelled the printer setup dialog,
End
End
End_Procedure
End_Object // oSetupButton
The printer must be setup before the report is run. If you attempt to invoke the print dialog while a report is active, either the dialog must be ignored or the report must be cleared. If the dialog is invoked while the report viewer is active, an error will be declared. If the dialog is invoked when the report is completed but the viewer is not active (this should be rare), the current report is cleared and the dialog is presented. You can always manually clear a report before invoking the printer setup dialog by sending the DfClearDoc message.
Object oSetupButton is a Button
Set Label to "Printer Setup"
Set Location to 7 120
Procedure OnClick
Boolean bOk
// make sure we are always allowed to use the dialog
Send DFClearDoc of oOrdersReport
Get DFPrintSetupDialog of oOrdersReport to bOk
End_Procedure
End_Object // oSetupButton
See Also
DfClearDoc | IsViewerActive | DocumentStatus
Return Value
Returns True of the selection was OKed, False if the dialog was canceled