Dlg Print Command

Purpose

calls the common printer selecting dialog box. Implemented for compatibility reasons only. It is advised not to use this command and instead use CommDlg object.

Syntax

Dlg Print form, Flags%, hDC

Description

form is a Form object like me, Win_1, Dlg_1, frm1.

Flags% declares some bit-wise settings:

PD_ALLPAGES $000000 Sets all Radio Buttons On.
PD_SELECTION $000001 Sets the selection Radio Button to On.
PD_PAGENUMS $000002 Sets the pages Radio Button to On.
PD_NOSELECTION $000004 Print selection disabled.
PD_NOPAGENUMS $000008 Page numbers disabled.
PD_COLLATE $000010 Sets the Collate Copies check box to On.
PD_PRINTTOFILE $000020 Sets the Print to File check box to On.
PD_PRINTSETUP $000040 Calls the Setup Dialog. (The Setup Button also allows the user to call up the Setup Dialog directly.)
PD_NOWARNING $000080 Warnings about errors in the Default Printer are suppressed.
PD_USEDEVMODECOPIES $040000 If a printer driver can make copies itself it is used instead of the Print Manager.
PD_DISABLEPRINTTOFILE $080000 Print to File is disabled.
PD_HIDEPRINTTOFILE $100000 The Print to File check box is hidden.

GFA-BASIC does not allow the following:

PD_RETURNDC $000100 always returns a DC.
PD_RETURNIC $000200
PD_RETURNDEFAULT $000400
PD_SHOWHELP $000800
PD_ENABLEPRINTHOOK $001000
PD_ENABLESETUPHOOK $002000
PD_ENABLEPRINTTEMPLATE $004000
PD_ENABLESETUPTEMPLATE $008000
PD_ENABLEPRINTTEMPLATEHANDLE $010000
PD_ENABLESETUPTEMPLATEHANDLE $020000

hDC is the return value, this is a device context like PrinterDC().

_AX is null, if an error has occurred. Otherwise, _BX is the "from page(i.e.: Starting Page).

_CX is the "to" page(i.e.: Ending Page).

_EX is the number of copies.

_EFL holds the new values for the flags:

_EFL %& PD_PAGEENUMS is not equal to zero when a range of page number button is chosen

_EFL %& PD_SELECTION is not equal to zero when selection button is chosen, and so forth.

_SI is the handle of the internal hDevMode structure.

_DI is the handle of the internal hDevNames structure.

Special: When _AX = $1234 some parameters can be set prior to the call from Dlg Print.

_BX beginning page;
_CX ending page,
_DX number of copies;
_SI smallest page number;
_DI largest page number (without these settings, the page numbers lie between 0 and 100).

Example

OpenW 1

Local h As Handle

Dlg Print Win_1, 0, h

If Not IsNull(h)

SetPrinterHDC h

Output = Printer

Printer.FontSize = 12 : Printer.FontName = "Arial"

Printer.StartDoc "GFA Test"

Printer.StartPage

Print "Hello World"

Printer.FontName = "courier new"

Text 200, 400, "Hello World 2"

Printer.EndPage

Printer.EndDoc

Output = Win_1

EndIf

CloseW 1

Alternatively, you can use CommDlg Print as in the following example:"

OpenW 1

Print " Start printing"

//

// to use the Ocx Commdlg with the name cd

Ocx CommDlg cd

// to make Cancel possible

cd.CancelError = True

// to show the printer dialog

cd.ShowPrint

//to choose the printer and to activate it in the following

Set Printer = cd

// to set one flag

cd.Flags = cdpDisablePrintToFile

// all output to the printer

Output = Printer

// to start the print job

Printer.StartDoc "Text"

// 1. start page of your printing

Printer.StartPage

// to use a font

Printer.FontName = "Arial"

// to use a font size

Printer.FontSize = 16

Print "Hello GFA"

DefLine 10, 2

Circle 100, 100, 300

Box 150, 150, 240, 240

// end ot the page

Printer.EndPage

// end of the print job

Printer.EndDoc

// output back into the actual window

Output = Win_1

Print "printing is finished"

Print

Print "press Alt F4 to end"

Do : Sleep : Until Me Is Nothing

See Also

CommDlg, Printer

{Created by Sjouke Hamstra; Last updated: 24/11/2015 by James Gaite}