Guidance
指路人
g.yi.org
software / rapidq / Examples / Devices / Printer & Parallel Port / win32 api printer / Printer.BAS

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' Printer.BAS was programmed by John White (danilo_yoingco@yahoo.co.uk).

     $OPTIMIZE ON
     $APPTYPE GUI
     $TYPECHECK ON
     $ESCAPECHARS ON

' Printer.BAS`s own CONST Values.
     CONST DATA_TO_PRINTER=0
     CONST DATA_TO_OUTPUT=1
     CONST DDM_COPYTO_PI2DM=0
     CONST PI2DM_COPYTO_DDM=1
     CONST ENUMERATE_PRINTERS=0
     CONST ENUMERATE_DEFAULT_PRINTER=1
     CONST SET_DDM=0
     CONST SET_PI2DM=1
     CONST SET_BOTH_DM=2

     CONST fmCreate = 65535
     CONST fmOpenRead = 0
     CONST fmOpenWrite = 1
     CONST fmOpenReadWrite = 2

     CONST ERROR_INSUFFICIENT_BUFFER = 122
     CONST PRINTER_ENUM_LOCAL = &H2
     CONST DM_UPDATE = 1
     CONST DM_COPY = 2
     CONST DM_PROMPT = 4
     CONST DM_MODIFY = 8
     CONST IDOK = 1
     CONST IDCANCEL = 2
     CONST IDABORT = 3
     CONST IDRETRY = 4
     CONST IDIGNORE = 5
     CONST IDYES = 6
     CONST IDNO = 7
     CONST GMEM_FIXED = &H0
     CONST GMEM_MOVEABLE = &H2
     CONST GMEM_ZEROINIT = &H40
     CONST GMEM_INVALID_HANDLE = &H8000
     CONST PS_SOLID = 0
     CONST GDI_ERROR = &HFFFF
     CONST PRINTER_ACCESS_ADMINISTER = &H4
     CONST PRINTER_ACCESS_USE = &H8
     CONST STANDARD_RIGHTS_REQUIRED = &HF0000
     CONST STANDARD_RIGHTS_ALL = &H1F0000
     CONST DC_FIELDS = 1
     CONST DC_PAPERS = 2
     CONST DC_PAPERSIZE = 3
     CONST DC_MINEXTENT = 4
     CONST DC_MAXEXTENT = 5
     CONST DC_BINS = 6
     CONST DC_DUPLEX = 7
     CONST DC_SIZE = 8
     CONST DC_EXTRA = 9
     CONST DC_VERSION = 10
     CONST DC_DRIVER = 11
     CONST DC_BINNAMES = 12
     CONST DC_ENUMRESOLUTIONS = 13
     CONST DC_FILEDEPENDENCIES = 14
     CONST DC_TRUETYPE = 15
     CONST DC_PAPERNAMES = 16
     CONST DC_ORIENTATION = 17
     CONST DC_COPIES = 18
     CONST DC_BINADJUST = 19
     CONST DC_EMF_COMPLIANT = 20
     CONST DC_DATATYPE_PRODUCED = 21
     CONST DC_COLLATE = 22
     CONST DCTT_BITMAP = 1            '  print TT fonts as graphics
     CONST DCTT_DOWNLOAD = 2          '  download TT fonts as soft fonts
     CONST DCTT_SUBDEV = 3            '  substitute device fonts for TT fonts
     CONST DI_APPBANDING = &H1
     CONST DI_ROPS_READ_DESTINATION = &H2
     CONST PHYSICALWIDTH = 110 '  Physical Width in device units
     CONST PHYSICALHEIGHT = 111 '  Physical Height in device units
     CONST PHYSICALOFFSETX = 112 '  Physical Printable Area x margin
     CONST PHYSICALOFFSETY = 113 '  Physical Printable Area y margin
     CONST SCALINGFACTORX = 114 '  Scaling factor x
     CONST SCALINGFACTORY = 115 '  Scaling factor y
     CONST CURVECAPS = 28         '  Curve capabilities
     CONST LINECAPS = 30          '  Line capabilities
     CONST POLYGONALCAPS = 32     '  Polygonal capabilities
     CONST TEXTCAPS = 34          '  Text capabilities
     CONST CLIPCAPS = 36          '  Clipping capabilities
     CONST RASTERCAPS = 38        '  Bitblt capabilities
     CONST PRINTER_ATTRIBUTE_QUEUED = &H1
     CONST PRINTER_ATTRIBUTE_DIRECT = &H2
     CONST PRINTER_ATTRIBUTE_DEFAULT = &H4
     CONST PRINTER_ATTRIBUTE_SHARED = &H8
     CONST PRINTER_ATTRIBUTE_NETWORK = &H10
     CONST PRINTER_ATTRIBUTE_HIDDEN = &H20
     CONST PRINTER_ATTRIBUTE_LOCAL = &H40
     CONST JOB_STATUS_PAUSED = &H1
     CONST JOB_STATUS_ERROR = &H2
     CONST JOB_STATUS_DELETING = &H4
     CONST JOB_STATUS_SPOOLING = &H8
     CONST JOB_STATUS_PRINTING = &H10
     CONST JOB_STATUS_OFFLINE = &H20
     CONST JOB_STATUS_PAPEROUT = &H40
     CONST JOB_STATUS_PRINTED = &H80
     CONST NO_PRIORITY = 0
     CONST MAX_PRIORITY = 99
     CONST MIN_PRIORITY = 1
     CONST DEF_PRIORITY = 1
     CONST JOB_CONTROL_PAUSE = 1
     CONST JOB_CONTROL_RESUME = 2
     CONST JOB_CONTROL_CANCEL = 3
     CONST JOB_CONTROL_RESTART = 4
     CONST JOB_POSITION_UNSPECIFIED = 0
     CONST PT_CLOSEFIGURE = &H1
     CONST PT_LINETO = &H2
     CONST PT_BEZIERTO = &H4
     CONST PT_MOVETO = &H6
     CONST BS_SOLID = 0
     CONST BS_NULL = 1
     CONST BS_HOLLOW = BS_NULL
     CONST BS_HATCHED = 2
     CONST BS_PATTERN = 3
     CONST BS_INDEXED = 4
     CONST BS_DIBPATTERN = 5
     CONST BS_DIBPATTERNPT = 6
     CONST BS_PATTERN8X8 = 7
     CONST BS_DIBPATTERN8X8 = 8
     CONST HS_HORIZONTAL = 0              '  -----
     CONST HS_VERTICAL = 1                '  |||||
     CONST HS_FDIAGONAL = 2               '  \\\\\
     CONST HS_BDIAGONAL = 3               '  /////
     CONST HS_CROSS = 4                   '  +++++
     CONST WHITE_BRUSH = 0
     CONST BLACK_BRUSH = 4
     CONST WHITE_PEN = 6
     CONST BLACK_PEN = 7
     CONST NULL_PEN = 8
     CONST OEM_FIXED_FONT = 10
     CONST ANSI_FIXED_FONT = 11
     CONST ANSI_VAR_FONT = 12
     CONST SYSTEM_FONT = 13
     CONST DEVICE_DEFAULT_FONT = 14
     CONST DEFAULT_PALETTE = 15
     CONST SYSTEM_FIXED_FONT = 16
     CONST CLR_INVALID = &HFFFF
     CONST TRANSPARENT = 1
     CONST OPAQUE = 2
     CONST DT_TOP = &H0
     CONST DT_LEFT = &H0
     CONST DT_CENTER = &H1
     CONST DT_RIGHT = &H2
     CONST DT_VCENTER = &H4
     CONST DT_BOTTOM = &H8
     CONST DT_WORDBREAK = &H10
     CONST DT_SINGLELINE = &H20
     CONST DT_EXPANDTABS = &H40
     CONST DT_TABSTOP = &H80
     CONST DT_NOCLIP = &H100
     CONST DT_EXTERNALLEADING = &H200
     CONST DT_CALCRECT = &H400
     CONST DT_NOPREFIX = &H800
     CONST DT_INTERNAL = &H1000
     CONST FW_DONTCARE = 0
     CONST FW_THIN = 100
     CONST FW_EXTRALIGHT = 200
     CONST FW_LIGHT = 300
     CONST FW_NORMAL = 400
     CONST FW_MEDIUM = 500
     CONST FW_SEMIBOLD = 600
     CONST FW_BOLD = 700
     CONST FW_EXTRABOLD = 800
     CONST FW_HEAVY = 900
     CONST ITALIC_OFF = 0
     CONST ITALIC_ON = 1
     CONST UNDERLINE_OFF = 0
     CONST UNDERLINE_ON = 1
     CONST STRIKEOUT_OFF = 0
     CONST STRIKEOUT_ON = 1
     CONST OUT_DEFAULT_PRECIS = 0
     CONST OUT_STRING_PRECIS = 1
     CONST OUT_CHARACTER_PRECIS = 2
     CONST OUT_STROKE_PRECIS = 3
     CONST OUT_TT_PRECIS = 4
     CONST OUT_DEVICE_PRECIS = 5
     CONST OUT_RASTER_PRECIS = 6
     CONST OUT_TT_ONLY_PRECIS = 7
     CONST OUT_OUTLINE_PRECIS = 8
     CONST CLIP_DEFAULT_PRECIS = 0
     CONST CLIP_CHARACTER_PRECIS = 1
     CONST CLIP_STROKE_PRECIS = 2
     CONST CLIP_MASK = &HF
     CONST CLIP_LH_ANGLES = 16
     CONST CLIP_TT_ALWAYS = 32
     CONST CLIP_EMBEDDED = 128
     CONST DEFAULT_QUALITY = 0
     CONST DRAFT_QUALITY = 1
     CONST PROOF_QUALITY = 2
     CONST DEFAULT_PITCH = 0
     CONST FIXED_PITCH = 1
     CONST VARIABLE_PITCH = 2
     CONST ANSI_CHARSET = 0
     CONST DEFAULT_CHARSET = 1
     CONST SYMBOL_CHARSET = 2
     CONST SHIFTJIS_CHARSET = 128
     CONST HANGEUL_CHARSET = 129
     CONST CHINESEBIG5_CHARSET = 136
     CONST OEM_CHARSET = 255
     CONST FF_DONTCARE = 0
     CONST FF_ROMAN = 16
     CONST FF_SWISS = 32
     CONST FF_MODERN = 48
     CONST FF_SCRIPT = 64
     CONST FF_DECORATIVE = 80
     CONST LOGPIXELSX = 88        '  Logical pixels/inch in X
     CONST LOGPIXELSY = 90        '  Logical pixels/inch in Y
     CONST MM_TEXT = 1
     CONST MM_LOMETRIC = 2
     CONST MM_HIMETRIC = 3
     CONST MM_LOENGLISH = 4
     CONST MM_HIENGLISH = 5
     CONST MM_TWIPS = 6
     CONST MM_ISOTROPIC = 7
     CONST MM_ANISOTROPIC = 8
     CONST GM_COMPATIBLE = 1
     CONST GM_ADVANCED = 2
     CONST TA_NOUPDATECP = 0
     CONST TA_UPDATECP = 1
     CONST TA_LEFT = 0
     CONST TA_RIGHT = 2
     CONST TA_CENTER = 6
     CONST TA_TOP = 0
     CONST TA_BOTTOM = 8
     CONST TA_BASELINE = 24
     CONST TA_MASK = (TA_BASELINE + TA_CENTER + TA_UPDATECP)
     CONST VTA_BASELINE = TA_BASELINE
     CONST VTA_LEFT = TA_BOTTOM
     CONST VTA_RIGHT = TA_TOP
     CONST VTA_CENTER = TA_CENTER
     CONST VTA_BOTTOM = TA_RIGHT
     CONST VTA_TOP = TA_LEFT
     CONST DM_ORIENTATION = &H1&
     CONST DM_PAPERSIZE = &H2&
     CONST DM_PAPERLENGTH = &H4&
     CONST DM_PAPERWIDTH = &H8&
     CONST DM_SCALE = &H10&
     CONST DM_COPIES = &H100&
     CONST DM_DEFAULTSOURCE = &H200&
     CONST DM_PRINTQUALITY = &H400&
     CONST DM_COLOR = &H800&
     CONST DM_DUPLEX = &H1000&
     CONST DM_YRESOLUTION = &H2000&
     CONST DM_TTOPTION = &H4000&
     CONST DM_COLLATE AS LONG = &H8000
     CONST DM_FORMNAME AS LONG = &H10000
     CONST DMORIENT_PORTRAIT = 1
     CONST DMORIENT_LANDSCAPE = 2
     CONST HWND_BROADCAST = &HFFFF
     CONST SMTO_NORMAL = &H0
     CONST WM_DEVMODECHANGE = &H1B
     CONST WM_SETTINGCHANGE = 26
     CONST PSD_MINMARGINS = &H1 '  use caller's
     CONST PSD_MARGINS = &H2 '  use caller's
     CONST PSD_INTHOUSANDTHSOFINCHES = &H4 '  2nd of 4 possible
     CONST PSD_INHUNDREDTHSOFMILLIMETERS = &H8 '  3rd of 4 possible
     CONST PSD_DISABLEMARGINS = &H10
     CONST PSD_DISABLEPRINTER = &H20
     CONST PSD_NOWARNING = &H80 '  must be same as PD_*
     CONST PSD_DISABLEORIENTATION = &H100
     CONST PSD_RETURNDEFAULT = &H400 '  must be same as PD_*
     CONST PSD_DISABLEPAPER = &H200
     CONST PSD_SHOWHELP = &H800 '  must be same as PD_*
     CONST PSD_ENABLEPAGESETUPHOOK = &H2000 '  must be same as PD_*
     CONST PSD_ENABLEPAGESETUPTEMPLATE = &H8000 '  must be same as PD_*
     CONST PSD_ENABLEPAGESETUPTEMPLATEHANDLE = &H20000 '  must be same as PD_*
     CONST PSD_ENABLEPAGEPAINTHOOK = &H40000
     CONST PSD_DISABLEPAGEPAINTING = &H80000
     CONST DN_DEFAULTPRN = &H1
     CONST PD_ALLPAGES = &H0
     CONST PD_SELECTION = &H1
     CONST PD_PAGENUMS = &H2
     CONST PD_NOSELECTION = &H4
     CONST PD_NOPAGENUMS = &H8
     CONST PD_COLLATE = &H10
     CONST PD_PRINTTOFILE = &H20
     CONST PD_PRINTSETUP = &H40
     CONST PD_NOWARNING = &H80
     CONST PD_RETURNDC = &H100
     CONST PD_RETURNIC = &H200
     CONST PD_RETURNDEFAULT = &H400
     CONST PD_SHOWHELP = &H800
     CONST PD_ENABLEPRINTHOOK = &H1000
     CONST PD_ENABLESETUPHOOK = &H2000
     CONST PD_ENABLEPRINTTEMPLATE = &H4000
     CONST PD_ENABLESETUPTEMPLATE = &H8000
     CONST PD_ENABLEPRINTTEMPLATEHANDLE = &H10000
     CONST PD_ENABLESETUPTEMPLATEHANDLE = &H20000
     CONST PD_USEDEVMODECOPIES = &H40000
     CONST PD_USEDEVMODECOPIESANDCOLLATE = &H40000
     CONST PD_DISABLEPRINTTOFILE = &H80000
     CONST PD_HIDEPRINTTOFILE = &H100000
     CONST PD_NONETWORKBUTTON = &H200000
     CONST RC_NONE = 0
     CONST RC_BITBLT = 1                  '  Can do standard BLT.
     CONST RC_BANDING = 2                 '  Device requires banding support
     CONST RC_SCALING = 4                 '  Device requires scaling support
     CONST RC_BITMAP64 = 8                '  Device can support >64K bitmap
     CONST RC_GDI20_OUTPUT = &H10             '  has 2.0 output calls
     CONST RC_GDI20_STATE = &H20
     CONST RC_SAVEBITMAP = &H40
     CONST RC_DI_BITMAP = &H80                '  supports DIB to memory
     CONST RC_PALETTE = &H100                 '  supports a palette
     CONST RC_DIBTODEV = &H200                '  supports DIBitsToDevice
     CONST RC_BIGFONT = &H400                 '  supports >64K fonts
     CONST RC_STRETCHBLT = &H800              '  supports StretchBlt
     CONST RC_FLOODFILL = &H1000              '  supports FloodFill
     CONST RC_STRETCHDIB = &H2000             '  supports StretchDIBits
     CONST RC_OP_DX_OUTPUT = &H4000
     CONST RC_DEVBITS = &H8000
     CONST SRCCOPY = &HCC0020         ' (DWORD) dest = source
     CONST SRCPAINT = &HEE0086        ' (DWORD) dest = source OR dest
     CONST SRCAND = &H8800C6          ' (DWORD) dest = source AND dest
     CONST SRCINVERT = &H660046       ' (DWORD) dest = source XOR dest
     CONST SRCERASE = &H440328        ' (DWORD) dest = source AND (NOT dest )
     CONST NOTSRCCOPY = &H330008      ' (DWORD) dest = (NOT source)
     CONST NOTSRCERASE = &H1100A6     ' (DWORD) dest = (NOT src) AND (NOT dest)
     CONST MERGECOPY = &HC000CA       ' (DWORD) dest = (source AND pattern)
     CONST MERGEPAINT = &HBB0226      ' (DWORD) dest = (NOT source) OR dest
     CONST PATCOPY = &HF00021         ' (DWORD) dest = pattern
     CONST PATPAINT = &HFB0A09        ' (DWORD) dest = DPSnoo
     CONST PATINVERT = &H5A0049       ' (DWORD) dest = pattern XOR dest
     CONST DSTINVERT = &H550009       ' (DWORD) dest = (NOT dest)
     CONST BLACKNESS = &H42           ' (DWORD) dest = BLACK
     CONST WHITENESS = &HFF0062       ' (DWORD) dest = WHITE
     CONST HGDI_ERROR = &HFFFF
     CONST BLACKONWHITE = 1
     CONST WHITEONBLACK = 2
     CONST COLORONCOLOR = 3
     CONST HALFTONE = 4
     CONST MAXSTRETCHBLTMODE = 4
     CONST BDR_RAISEDOUTER = &H1
     CONST BDR_SUNKENOUTER = &H2
     CONST BDR_RAISEDINNER = &H4
     CONST BDR_SUNKENINNER = &H8
     CONST BDR_OUTER = &H3
     CONST BDR_INNER = &HC
     CONST BDR_RAISED = &H5
     CONST BDR_SUNKEN = &HA
     CONST EDGE_RAISED = (BDR_RAISEDOUTER OR BDR_RAISEDINNER)
     CONST EDGE_SUNKEN = (BDR_SUNKENOUTER OR BDR_SUNKENINNER)
     CONST EDGE_ETCHED = (BDR_SUNKENOUTER OR BDR_RAISEDINNER)
     CONST EDGE_BUMP = (BDR_RAISEDOUTER OR BDR_SUNKENINNER)
     CONST BF_LEFT = &H1
     CONST BF_TOP = &H2
     CONST BF_RIGHT = &H4
     CONST BF_BOTTOM = &H8
     CONST BF_TOPLEFT = (BF_TOP OR BF_LEFT)
     CONST BF_TOPRIGHT = (BF_TOP OR BF_RIGHT)
     CONST BF_BOTTOMLEFT = (BF_BOTTOM OR BF_LEFT)
     CONST BF_BOTTOMRIGHT = (BF_BOTTOM OR BF_RIGHT)
     CONST BF_RECT = (BF_LEFT OR BF_TOP OR BF_RIGHT OR BF_BOTTOM)
     CONST BF_DIAGONAL = &H10
     CONST BF_DIAGONAL_ENDTOPRIGHT = (BF_DIAGONAL OR BF_TOP OR BF_RIGHT)
     CONST BF_DIAGONAL_ENDTOPLEFT = (BF_DIAGONAL OR BF_TOP OR BF_LEFT)
     CONST BF_DIAGONAL_ENDBOTTOMLEFT = (BF_DIAGONAL OR BF_BOTTOM OR BF_LEFT)
     CONST BF_DIAGONAL_ENDBOTTOMRIGHT = (BF_DIAGONAL OR BF_BOTTOM OR BF_RIGHT)
     CONST BF_MIDDLE = &H800    ' Fill in the middle.
     CONST BF_SOFT = &H1000     ' Use for softer buttons.
     CONST BF_ADJUST = &H2000   ' Calculate the space left over.
     CONST BF_FLAT = &H4000     ' For flat rather than 3-D borders.
     CONST BF_MONO = &H8000     ' For monochrome borders.
     CONST PORT_TYPE_WRITE=1
     CONST PORT_TYPE_READ=2
     CONST PORT_TYPE_REDIRECTED=4
     CONST PORT_TYPE_NET_ATTACHED=8
     CONST DCBA_FACEUPNONE = &H0
     CONST DCBA_FACEUPCENTER = &H1
     CONST DCBA_FACEUPLEFT = &H2
     CONST DCBA_FACEUPRIGHT = &H3
     CONST DCBA_FACEDOWNNONE = &H100
     CONST DCBA_FACEDOWNCENTER = &H101
     CONST DCBA_FACEDOWNLEFT = &H102
     CONST DCBA_FACEDOWNRIGHT = &H103
     CONST DMDITHER_NONE = 1          '  No dithering
     CONST DMDITHER_COARSE = 2        '  Dither with a coarse brush
     CONST DMDITHER_FINE = 3          '  Dither with a fine brush
     CONST DMDITHER_LINEART = 4       '  LineArt dithering
     CONST DMDITHER_GRAYSCALE = 5     '  Device does grayscaling
     CONST DMDITHER_USER = 256        '  Device-specific dithers start here
     CONST DMCOLOR_MONOCHROME = 1
     CONST DMCOLOR_COLOR = 2
     CONST DMDUP_SIMPLEX = 1
     CONST DMDUP_VERTICAL = 2
     CONST DMDUP_HORIZONTAL = 3
     CONST DMPAPER_LETTER = 1                        '  Letter 8 1/2 x 11 in
     CONST DMPAPER_LETTERSMALL = 2            '  Letter Small 8 1/2 x 11 in
     CONST DMPAPER_TABLOID = 3                '  Tabloid 11 x 17 in
     CONST DMPAPER_LEDGER = 4                 '  Ledger 17 x 11 in
     CONST DMPAPER_LEGAL = 5                  '  Legal 8 1/2 x 14 in
     CONST DMPAPER_STATEMENT = 6              '  Statement 5 1/2 x 8 1/2 in
     CONST DMPAPER_EXECUTIVE = 7              '  Executive 7 1/4 x 10 1/2 in
     CONST DMPAPER_A3 = 8                     '  A3 297 x 420 mm
     CONST DMPAPER_A4 = 9                     '  A4 210 x 297 mm
     CONST DMPAPER_A4SMALL = 10               '  A4 Small 210 x 297 mm
     CONST DMPAPER_A5 = 11                    '  A5 148 x 210 mm
     CONST DMPAPER_B4 = 12                    '  B4 250 x 354
     CONST DMPAPER_B5 = 13                    '  B5 182 x 257 mm
     CONST DMPAPER_FOLIO = 14                 '  Folio 8 1/2 x 13 in
     CONST DMPAPER_QUARTO = 15                '  Quarto 215 x 275 mm
     CONST DMPAPER_10X14 = 16                 '  10x14 in
     CONST DMPAPER_11X17 = 17                 '  11x17 in
     CONST DMPAPER_NOTE = 18                  '  Note 8 1/2 x 11 in
     CONST DMPAPER_ENV_9 = 19                 '  Envelope #9 3 7/8 x 8 7/8
     CONST DMPAPER_ENV_10 = 20                '  Envelope #10 4 1/8 x 9 1/2
     CONST DMPAPER_ENV_11 = 21                '  Envelope #11 4 1/2 x 10 3/8
     CONST DMPAPER_ENV_12 = 22                '  Envelope #12 4 \276 x 11
     CONST DMPAPER_ENV_14 = 23                '  Envelope #14 5 x 11 1/2
     CONST DMPAPER_CSHEET = 24                '  C size sheet
     CONST DMPAPER_DSHEET = 25                '  D size sheet
     CONST DMPAPER_ESHEET = 26                '  E size sheet
     CONST DMPAPER_ENV_DL = 27                '  Envelope DL 110 x 220mm
     CONST DMPAPER_ENV_C5 = 28                '  Envelope C5 162 x 229 mm
     CONST DMPAPER_ENV_C3 = 29                '  Envelope C3  324 x 458 mm
     CONST DMPAPER_ENV_C4 = 30                '  Envelope C4  229 x 324 mm
     CONST DMPAPER_ENV_C6 = 31                '  Envelope C6  114 x 162 mm
     CONST DMPAPER_ENV_C65 = 32               '  Envelope C65 114 x 229 mm
     CONST DMPAPER_ENV_B4 = 33                '  Envelope B4  250 x 353 mm
     CONST DMPAPER_ENV_B5 = 34                '  Envelope B5  176 x 250 mm
     CONST DMPAPER_ENV_B6 = 35                '  Envelope B6  176 x 125 mm
     CONST DMPAPER_ENV_ITALY = 36             '  Envelope 110 x 230 mm
     CONST DMPAPER_ENV_MONARCH = 37           '  Envelope Monarch 3.875 x 7.5 in
     CONST DMPAPER_ENV_PERSONAL = 38          '  6 3/4 Envelope 3 5/8 x 6 1/2 in
     CONST DMPAPER_FANFOLD_US = 39            '  US Std Fanfold 14 7/8 x 11 in
     CONST DMPAPER_FANFOLD_STD_GERMAN = 40    '  German Std Fanfold 8 1/2 x 12 in
     CONST DMPAPER_FANFOLD_LGL_GERMAN = 41    '  German Legal Fanfold 8 1/2 x 13 in
     CONST DMPAPER_USER = 256
     CONST DMBIN_ONLYONE = 1
     CONST DMBIN_LOWER = 2
     CONST DMBIN_MIDDLE = 3
     CONST DMBIN_MANUAL = 4
     CONST DMBIN_ENVELOPE = 5
     CONST DMBIN_ENVMANUAL = 6
     CONST DMBIN_AUTO = 7
     CONST DMBIN_TRACTOR = 8
     CONST DMBIN_SMALLFMT = 9
     CONST DMBIN_LARGEFMT = 10
     CONST DMBIN_LARGECAPACITY = 11
     CONST DMBIN_CASSETTE = 14
     CONST DMBIN_USER = 256
     CONST DMRES_DRAFT = (-1)
     CONST DMRES_LOW = (-2)
     CONST DMRES_MEDIUM = (-3)
     CONST DMRES_HIGH = (-4)
     CONST DMTT_BITMAP = 1            '  print TT fonts as graphics
     CONST DMTT_DOWNLOAD = 2          '  download TT fonts as soft fonts
     CONST DMTT_SUBDEV = 3            '  substitute device fonts for TT fonts
     CONST DMTT_DOWNLOAD_OUTLINE = 4 '  download TT fonts as outline soft
     CONST DMCOLLATE_FALSE = 0
     CONST DMCOLLATE_TRUE = 1
     CONST DMICMMETHOD_NONE = 1       '  ICM disabled
     CONST DMICMMETHOD_SYSTEM = 2     '  ICM handled by system
     CONST DMICMMETHOD_DRIVER = 3     '  ICM handled by driver
     CONST DMICMMETHOD_DEVICE = 4     '  ICM handled by device
     CONST DMICMMETHOD_USER = 256     '  Device-specific methods start here
     CONST DMICM_SATURATE = 1         '  Maximize color saturation
     CONST DMICM_CONTRAST = 2         '  Maximize color contrast
     CONST DMICM_COLORMETRIC = 3      '  Use specific color metric
     CONST DMICM_USER = 256           '  Device-specific intents start here
     CONST DMMEDIA_STANDARD = 1       '  Standard paper
     CONST DMMEDIA_TRANSPARENCY = 2   '  Transparency
     CONST DMMEDIA_GLOSSY = 3         '  Glossy paper
     CONST DMMEDIA_SPECIALPAPER=269   ' A driver-specific value, for the
     CONST DMMEDIA_BOND=268           ' HP DeskJet 680C printer-driver.

     DECLARE FUNCTION AbortDoc LIB "gdi32.dll" ALIAS "AbortDoc" (hdc AS LONG) AS LONG
     DECLARE FUNCTION AbortPrinter LIB "winspool.drv" ALIAS "AbortPrinter" (hPrinter AS LONG) AS LONG
     DECLARE FUNCTION AdvancedDocumentProperties LIB "winspool.drv" ALIAS "AdvancedDocumentPropertiesA" (hwnd AS LONG, hPrinter AS LONG, deviceName AS STRING, devmodeOutput AS LONG, devmodeInput AS LONG) AS LONG
     DECLARE FUNCTION AngleArc LIB "gdi32.dll" ALIAS "AngleArc" (hdc AS LONG, x AS LONG, y AS LONG, radius AS LONG, startAngle AS DOUBLE, sweepAngle AS DOUBLE) AS LONG
     DECLARE FUNCTION Arc LIB "gdi32.dll" ALIAS "Arc" (hdc AS LONG, x AS LONG, y AS LONG, x1 AS LONG, y1 AS LONG, x2 AS LONG, y2 AS LONG, x3 AS LONG, y3 AS LONG) AS LONG
     DECLARE FUNCTION ArcTo LIB "gdi32.dll" ALIAS "ArcTo" (hdc AS LONG, x AS LONG, y AS LONG, x1 AS LONG, y1 AS LONG, x2 AS LONG, y2 AS LONG, x3 AS LONG, y3 AS LONG) AS LONG
     DECLARE FUNCTION BitBlt LIB "gdi32.dll" ALIAS "BitBlt" (destDC AS LONG, x AS LONG, y AS LONG, width AS LONG, height AS LONG, sourceDC AS LONG, xSource AS LONG, ySource AS LONG, rop AS LONG) AS LONG
     DECLARE FUNCTION Chord LIB "gdi32.dll" ALIAS "Chord" (hdc AS LONG, left AS LONG, top AS LONG, right AS LONG, bottom AS LONG, r1 AS LONG, r2 AS LONG, r3 AS LONG, r4 AS LONG) AS LONG
     DECLARE FUNCTION ClosePrinter LIB "winspool.drv" ALIAS "ClosePrinter" (handle AS LONG) AS LONG
     DECLARE FUNCTION CommDlgExtendedError LIB "comdlg32.dll" ALIAS "CommDlgExtendedError" () AS LONG
     DECLARE FUNCTION ConfigurePort LIB "winspool.drv" ALIAS "ConfigurePortA" (serverName AS LONG, hwnd AS LONG, portName AS LONG) AS LONG
     DECLARE SUB CopyMemory LIB "kernel32.dll" ALIAS "RtlMoveMemory" (BYVAL dest AS LONG, BYVAL source AS LONG, BYVAL numBytes AS LONG)
     DECLARE FUNCTION CreateBitmap LIB "gdi32.dll" ALIAS "CreateBitmap" (width AS LONG, height AS LONG, planes AS LONG, bitCount AS LONG, bits AS WORD) AS LONG
     DECLARE FUNCTION CreateBrushIndirect LIB "gdi32.dll" ALIAS "CreateBrushIndirect" (Brush AS LONG) AS LONG
     DECLARE FUNCTION CreateDC LIB "gdi32.dll" ALIAS "CreateDCA" (driverName AS STRING, deviceName AS STRING, portName AS STRING, initData AS LONG) AS LONG
     DECLARE FUNCTION CreateFont LIB "gdi32.dll" ALIAS "CreateFontA" (H AS LONG, W AS LONG, E AS LONG, O AS LONG, Weight AS LONG, I AS LONG, U AS LONG, S AS LONG, CharSet AS LONG, OP AS LONG, CP AS LONG, Q AS LONG, PAF AS LONG, Font AS LONG) AS LONG
     DECLARE FUNCTION CreateFontIndirect LIB "gdi32.dll" ALIAS "CreateFontIndirectA" (fontData AS LONG) AS LONG
     DECLARE FUNCTION CreatePatternBrush LIB "gdi32.dll" ALIAS "CreatePatternBrush" (hBitmap AS LONG) AS LONG
     DECLARE FUNCTION CreatePen LIB "gdi32.dll" ALIAS "CreatePen" (penStyle AS LONG, nWidth AS LONG, colour AS LONG) AS LONG
     DECLARE FUNCTION CreateSolidBrush LIB "gdi32.dll" ALIAS "CreateSolidBrush" (colour AS LONG) AS LONG
     DECLARE FUNCTION DeleteDC LIB "gdi32.dll" ALIAS "DeleteDC" (hdc AS LONG) AS LONG
     DECLARE FUNCTION DeleteObject LIB "gdi32.dll" ALIAS "DeleteObject" (hObject AS LONG) AS LONG
     DECLARE FUNCTION DeletePrinter LIB "winspool.drv" ALIAS "DeletePrinter" (hPrinter AS LONG) AS LONG
     DECLARE FUNCTION DeletePrinterDriver LIB "winspool.drv" ALIAS "DeletePrinterDriverA" (serverName AS LONG, environment AS LONG, driverName AS LONG) AS LONG
     DECLARE FUNCTION DeviceCapabilities LIB "winspool.drv" ALIAS "DeviceCapabilitiesA" (deviceName AS STRING, portName AS STRING, query_flag AS LONG, buffer AS LONG, devMode AS LONG) AS LONG
     DECLARE FUNCTION DocumentProperties LIB "winspool.drv" ALIAS "DocumentPropertiesA" (hwindow AS LONG, hprinter AS LONG, deviceName AS STRING, outDevMode AS LONG, inDevMode AS LONG, fMode AS LONG) AS LONG
     DECLARE FUNCTION DrawEdge LIB "user32.dll" ALIAS "DrawEdge" (hdc AS LONG, edgeRect AS LONG, edge AS LONG, flags AS LONG) AS LONG
     DECLARE FUNCTION DrawText LIB "user32.dll" ALIAS "DrawTextA" (hdc AS LONG, buf AS BYTE, bufsize AS LONG, rect AS LONG, format AS LONG) AS LONG
     DECLARE FUNCTION Ellipse LIB "gdi32.dll" ALIAS "Ellipse" (hdc AS LONG, X1 AS LONG, Y1 AS LONG, X2 AS LONG, Y2 AS LONG) AS LONG
     DECLARE FUNCTION EndDoc LIB "gdi32.dll" ALIAS "EndDoc" (hdc AS LONG) AS LONG
     DECLARE FUNCTION EndDocPrinter LIB "winspool.drv" ALIAS "EndDocPrinter" (hPrinter AS LONG) AS LONG
     DECLARE FUNCTION EndPage LIB "gdi32.dll" ALIAS "EndPage" (hdc AS LONG) AS LONG
     DECLARE FUNCTION EndPagePrinter LIB "winspool.drv" ALIAS "EndPagePrinter" (hPrinter AS LONG) AS LONG
     DECLARE FUNCTION EnumJobs LIB "winspool.drv" ALIAS "EnumJobsA" (handle AS LONG, firstJob AS LONG, numJobs AS LONG, level AS LONG, buf AS LONG, bufsize AS LONG, needed AS LONG, returned AS LONG) AS LONG
     DECLARE FUNCTION EnumPorts LIB "winspool.drv" ALIAS "EnumPortsA" (serverName AS STRING, level AS LONG, buffer AS LONG, bufsize AS LONG, needed AS LONG, returned AS LONG) AS LONG
     DECLARE FUNCTION EnumPrinterDrivers LIB "winspool.drv" ALIAS "EnumPrinterDriversA" (serverName AS STRING, environment AS LONG, level AS LONG, buffer AS LONG, bufsize AS LONG, needed AS LONG, retruned AS LONG) AS LONG
     DECLARE FUNCTION EnumPrinters LIB "winspool.drv" ALIAS "EnumPrintersA" (flags AS LONG, name AS STRING, level AS LONG, buf AS LONG, bufsize AS LONG, needed AS LONG, returned AS LONG) AS LONG
     DECLARE FUNCTION ESCAPE LIB "gdi32.dll" ALIAS "Escape" (hdc AS LONG, ESCAPE AS LONG, bufsize AS LONG, buffer AS LONG, outData AS LONG) AS LONG
     DECLARE FUNCTION ExtEscape LIB "gdi32.dll" ALIAS "ExtEscape" (hdc AS LONG, ESCAPE AS LONG, bufsize1 AS LONG, buffer1 AS LONG, bufsize2 AS LONG, buffer2 AS LONG) AS LONG
     DECLARE FUNCTION FillRect LIB "user32.dll" ALIAS "FillRect" (hdc AS LONG, rect AS LONG, hBrush AS LONG) AS LONG
     DECLARE FUNCTION FrameRect LIB "user32.dll" ALIAS "FrameRect" (hdc AS LONG, frameRect AS LONG, hBrush AS LONG) AS LONG
     DECLARE FUNCTION GetBkColor LIB "gdi32.dll" ALIAS "GetBkColor" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GetBkMode LIB "gdi32.dll" ALIAS "GetBkMode" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GetDC LIB "user32.dll" ALIAS "GetDC" (hwnd AS LONG) AS LONG
     DECLARE FUNCTION GetDesktopWindow LIB "user32.dll" ALIAS "GetDesktopWindow" () AS LONG
     DECLARE FUNCTION GetDeviceCaps LIB "gdi32.dll" ALIAS "GetDeviceCaps" (hdc AS LONG, query_flag AS LONG) AS LONG
     DECLARE FUNCTION GetJob LIB "winspool.drv" ALIAS "GetJobA" (hPrinter AS LONG, jobId AS LONG, level AS LONG, buf AS LONG, bufsize AS LONG, needed AS LONG) AS LONG
     DECLARE FUNCTION GetLastError LIB "kernel32" ALIAS "GetLastError" () AS LONG
     DECLARE FUNCTION GetGraphicsMode LIB "gdi32.dll" ALIAS "GetGraphicsMode" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GetMapMode LIB "gdi32.dll" ALIAS "GetMapMode" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GetPixel LIB "gdi32.dll" ALIAS "GetPixel" (hdc AS LONG, x AS LONG, y AS LONG) AS LONG
     DECLARE FUNCTION GetPrinter LIB "winspool.drv" ALIAS "GetPrinterA" (handle AS LONG, level AS LONG, buf AS LONG, bufsize AS LONG, needed AS LONG) AS LONG
     DECLARE FUNCTION GetPrinterDriver LIB "winspool.drv" ALIAS "GetPrinterDriverA" (hPrinter AS LONG, environment AS STRING, level AS LONG, buffer AS LONG, bufsize AS LONG, needed AS LONG) AS LONG
     DECLARE FUNCTION GetStockObject LIB "gdi32.dll" ALIAS "GetStockObject" (object AS LONG) AS LONG
     DECLARE FUNCTION GetStretchBltMode LIB "gdi32.dll" ALIAS "GetStretchBltMode" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GetTextAlign LIB "gdi32.dll" ALIAS "GetTextAlign" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GetTextCharacterExtra LIB "gdi32.dll" ALIAS "GetTextCharacterExtraA" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GetTextColor LIB "gdi32.dll" ALIAS "GetTextColor" (hdc AS LONG) AS LONG
     DECLARE FUNCTION GlobalAlloc LIB "kernel32.dll" ALIAS "GlobalAlloc" (flags AS LONG, numBytes AS LONG) AS LONG
     DECLARE FUNCTION GlobalFree LIB "kernel32.dll" ALIAS "GlobalFree" (hMem AS LONG) AS LONG
     DECLARE FUNCTION GlobalLock LIB "kernel32.dll" ALIAS "GlobalLock" (hMem AS LONG) AS LONG
     DECLARE FUNCTION GlobalUnlock LIB "kernel32.dll" ALIAS "GlobalUnlock" (hMem AS LONG) AS LONG
     DECLARE FUNCTION LineTo LIB "gdi32.dll" ALIAS "LineTo" (hdc AS LONG, x AS LONG, y AS LONG) AS LONG
     DECLARE FUNCTION MoveToEx LIB "gdi32.dll" ALIAS "MoveToEx" (hdc AS LONG, x AS LONG, y AS LONG, curPos AS LONG) AS LONG
     DECLARE FUNCTION MulDiv LIB "kernel32.dll" ALIAS "MulDiv" (number AS LONG, numerator AS LONG, denominator AS LONG) AS LONG
     DECLARE FUNCTION OpenPrinter LIB "winspool.drv" ALIAS "OpenPrinterA" (printerName AS STRING, handle AS LONG, pDefault AS LONG) AS LONG
     DECLARE FUNCTION PageSetupDlg LIB "comdlg32.dll" ALIAS "PageSetupDlgA" (pageSetupDialog AS LONG) AS LONG
     DECLARE FUNCTION PatBlt LIB "gdi32.dll" ALIAS "PatBlt" (hdc AS LONG, x AS LONG, y AS LONG, width AS LONG, height AS LONG, rop AS LONG) AS LONG
     DECLARE FUNCTION PolyBezier LIB "gdi32.dll" ALIAS "PolyBezier" (hdc AS LONG, points AS LONG, numPoints AS LONG) AS LONG
     DECLARE FUNCTION PolyBezierTo LIB "gdi32.dll" ALIAS "PolyBezierTo" (hdc AS LONG, points AS LONG, numPoints AS LONG) AS LONG
     DECLARE FUNCTION Polyline LIB "gdi32.dll" ALIAS "Polyline" (hdc AS LONG, points AS LONG, numPoints AS LONG) AS LONG
     DECLARE FUNCTION PolylineTo LIB "gdi32.dll" ALIAS "PolylineTo" (hdc AS LONG, points AS LONG, numPoints AS LONG) AS LONG
     DECLARE FUNCTION PrintDlg LIB "comdlg32.dll" ALIAS "PrintDlgA" (printDlg AS LONG) AS LONG
     DECLARE FUNCTION PrinterProperties LIB "winspool.drv" ALIAS "PrinterProperties" (hWindow AS LONG, hPrinter AS LONG) AS LONG
     DECLARE FUNCTION ReadPrinter LIB "winspool.drv" ALIAS "ReadPrinter" (hPrinter AS LONG, buffer AS LONG, bufsize AS LONG, bytesRead AS LONG) AS LONG
     DECLARE FUNCTION Rectangle LIB "gdi32.dll" ALIAS "Rectangle" (hdc AS LONG, X1 AS LONG, Y1 AS LONG, X2 AS LONG, Y2 AS LONG) AS LONG
     DECLARE FUNCTION ReleaseDC LIB "user32.dll" ALIAS "ReleaseDC" (hwnd AS LONG, hdc AS LONG) AS LONG
     DECLARE FUNCTION ResetDC LIB "gdi32.dll" ALIAS "ResetDCA" (hdc AS LONG, initData AS LONG) AS LONG
     DECLARE FUNCTION RoundRect LIB "gdi32.dll" ALIAS "RoundRect" (hdc AS LONG, X1 AS LONG, Y1 AS LONG, X2 AS LONG, Y2 AS LONG, X3 AS LONG, Y3 AS LONG) AS LONG
     DECLARE FUNCTION SelectObject LIB "gdi32.dll" ALIAS "SelectObject" (hdc AS LONG, hObject AS LONG) AS LONG
     DECLARE FUNCTION SetBkColor LIB "gdi32.dll" ALIAS "SetBkColor" (hdc AS LONG, colour AS LONG) AS LONG
     DECLARE FUNCTION SetBkMode LIB "gdi32.dll" ALIAS "SetBkMode" (hdc AS LONG, mode AS LONG) AS LONG
     DECLARE FUNCTION SetGraphicsMode LIB "gdi32.dll" ALIAS "SetGraphicsMode" (hdc AS LONG, mode AS LONG) AS LONG
     DECLARE FUNCTION SetJob LIB "winspool.drv" ALIAS "SetJobA" (hPrinter AS LONG, jobId AS LONG, level AS LONG, buf AS LONG, command AS LONG) AS LONG
     DECLARE FUNCTION SetLastError LIB "kernel32" ALIAS "SetLastError" (errorCode AS LONG) AS LONG
     DECLARE FUNCTION SetMapMode LIB "gdi32.dll" ALIAS "SetMapMode" (hdc AS LONG, mapMode AS LONG) AS LONG
     DECLARE FUNCTION SetMapperFlags LIB "gdi32.dll" ALIAS "SetMapperFlags" (hdc AS LONG, flag AS LONG) AS LONG
     DECLARE FUNCTION SetPixel LIB "gdi32.dll" ALIAS "SetPixel" (hdc AS LONG, x AS LONG, y AS LONG, colour AS LONG) AS LONG
     DECLARE FUNCTION SetPrinter LIB "winspool.drv" ALIAS "SetPrinterA" (hPrinter AS LONG, level AS LONG, buffer AS LONG, command AS LONG) AS LONG
     DECLARE FUNCTION SetStretchBltMode LIB "gdi32.dll" ALIAS "SetStretchBltMode" (hdc AS LONG, stretchMode AS LONG) AS LONG
     DECLARE FUNCTION SetTextAlign LIB "gdi32.dll" ALIAS "SetTextAlign" (hdc AS LONG, flags AS LONG) AS LONG
     DECLARE FUNCTION SetTextCharacterExtra LIB "gdi32.dll" ALIAS "SetTextCharacterExtraA" (hdc AS LONG, spacing AS LONG) AS LONG
     DECLARE FUNCTION SetTextColor LIB "gdi32.dll" ALIAS "SetTextColor" (hdc AS LONG, colour AS LONG) AS LONG
     DECLARE FUNCTION StartDoc LIB "gdi32.dll" ALIAS "StartDocA" (hdc AS LONG, docInfo AS LONG) AS LONG
     DECLARE FUNCTION StartDocPrinter LIB "winspool.drv" ALIAS "StartDocPrinterA" (hPrinter AS LONG, level AS LONG, docInfo AS LONG) AS LONG
     DECLARE FUNCTION StartPage LIB "gdi32.dll" ALIAS "StartPage" (hdc AS LONG) AS LONG
     DECLARE FUNCTION StartPagePrinter LIB "winspool.drv" ALIAS "StartPagePrinter" (hPrinter AS LONG) AS LONG
     DECLARE FUNCTION StretchBlt LIB "gdi32.dll" ALIAS "StretchBlt" (hdc AS LONG, x AS LONG, y AS LONG, width AS LONG, height AS LONG, sourceDC AS LONG, xSource AS LONG, ySource AS LONG, wSource AS LONG, hSource AS LONG, rop AS LONG) AS LONG
     DECLARE FUNCTION TextOut LIB "gdi32.dll" ALIAS "TextOutA" (hdc AS LONG, x AS LONG, y AS LONG, buffer AS LONG, bufsize AS LONG) AS LONG
     DECLARE FUNCTION WritePrinter LIB "winspool.drv" ALIAS "WritePrinter" (hPrinter AS LONG, buf AS BYTE, bufsize AS LONG, bytesWritten AS LONG) AS LONG

' IN GENERAL, PLEASE DO NOT TOUCH THE VARIABLES BELOW.

' Printer/Function Variables.
     DIM prt_Handle AS LONG, prt_DC AS LONG
     DIM prt_opened AS BYTE, prt_error AS BYTE
     DIM needed AS LONG, rtnval AS LONG, jobID AS LONG
     DIM dm_Memory AS LONG, dm_Default AS LONG, dm_mem AS BYTE
     DIM pi2_Memory AS LONG, pi2_Default AS LONG, pi2_mem AS BYTE
     DIM jobs_Memory AS LONG, jobs_Default AS LONG, jobs_mem AS BYTE
     DIM jobs_Lock AS LONG
     DIM job_Memory AS LONG, job_Default AS LONG, job_mem AS BYTE
     DIM job_Lock AS LONG
     DIM pd_Memory AS LONG, pd_Default AS LONG, pd_mem AS BYTE
     DIM pd_Lock AS LONG
     DIM pi2_DevMode
     DIM wsize AS LONG, hsize AS LONG, FAdr AS LONG, FLen AS LONG
     DIM FInt AS INTEGER, FLong AS LONG, FWord AS WORD, FByte AS BYTE
     DIM FLock AS LONG, pi2Lock AS LONG, dmLock AS LONG
     DIM FFour AS LONG, FTwo AS WORD, FOne AS BYTE

' Printer/Function Strings.
     DIM prt_Name$ AS STRING, prt_Port$ AS STRING, device_Name$ AS STRING
     DIM emf$ AS STRING, raw$ AS STRING, prt_Error$ AS STRING
     DIM driver_Name$ AS STRING, emf_Title$ AS STRING, raw_Title$ AS STRING
     DIM document_Dir$ AS STRING, document_File$ AS STRING
     DIM document_Name$ AS STRING, output_File$ AS STRING

' Printer/Memory Structure Variables.
     DIM ports(0 TO 500) AS LONG,drivers(0 TO 500) AS LONG
     DIM printers(0 TO 500) AS LONG,pDefault(0 TO 2) AS LONG
     DIM dtypes(0 TO 30) AS LONG
     DIM bins(0 TO 30) AS WORD, bin_Name$(0 TO 30) AS STRING
     DIM papers(0 TO 30) AS WORD, papersizes(0 TO 60) AS LONG
     DIM paper_Name$(0 TO 30) AS STRING
     DIM point(0 TO 1) AS LONG,resolutions(0 TO 30) AS LONG

     DIM brush(0 TO 2) AS LONG
     DIM rect(0 TO 3) AS LONG, curves(0 TO 50) AS LONG, dtRect(0 TO 1) AS LONG
     DIM raw_buffer(0 TO 1000) AS BYTE, points(0 TO 50) AS LONG
     DIM text_buffer(0 TO 1000) AS BYTE
     DIM dn(0 TO 4) AS LONG
     DIM eRect(0 TO 3) AS LONG, fRect(0 TO 3) AS LONG
     DIM bm_Handle AS LONG, bm_bitsArray(0 TO 200) AS WORD

' Printer Drawing variables.
     DIM pen AS LONG, oldpen AS LONG, pen_set AS BYTE
     DIM hbrush AS LONG, oldhbrush AS LONG, hbrush_set AS BYTE
     DIM sbrush AS LONG, oldsbrush AS LONG, sbrush_set AS BYTE
     DIM pbrush AS LONG, oldpbrush AS LONG, pbrush_set AS BYTE
     DIM sfont AS LONG, oldsfont AS LONG, sfont_set AS BYTE
     DIM sobject AS LONG, oldsobject AS LONG, sobject_set AS BYTE
     DIM oldBGColour AS LONG, bgColour AS LONG
     DIM oldBGMode AS LONG, bgMode AS LONG, pixelRGB AS LONG
     DIM oldMapFlags AS LONG, oldSM AS LONG, currentSM AS LONG
     DIM oldMapMode AS LONG, mapMode AS LONG
     DIM oldGraphicsMode AS LONG, graphicsMode AS LONG
     DIM oldtextalign AS LONG, textalign AS LONG
     DIM oldtextcolour AS LONG, textcolour AS LONG
     DIM oldtextspacing AS LONG, textspacing AS LONG
     DIM bm_Window AS LONG, bm_DC AS LONG

' Generic variables.
     DIM stg$ AS STRING, rtn AS LONG, count AS LONG
     DIM size AS LONG, file AS QFILESTREAM

     emf$="EMF" : emf_title$="EMF Data Document"
     raw$="RAW" : raw_title$="RAW Data Document"

     document_Dir$="C:\\My Documents\\"
     document_Name$="Test.txt"
     document_File$=document_Dir$+document_Name$
     output_File$=document_Dir$+"OutputFile.txt"

     FOR count=0 TO 30
      bin_Name$(count)=STRING$(26, 0)
      paper_Name$(count)=STRING$(66, 0)
     NEXT

' Fill the RAW buffer with random characters.
     RANDOMIZE(-5)
     FOR count=0 TO 999 : raw_buffer(count)=32+RND(85) : NEXT

     SUB Show_DevMode
      IF ((prt_opened=1) AND (dm_mem=1)) THEN
       SHOWMESSAGE("DevMode - DeviceName: "+VARPTR$(dm_Default))
       CopyMemory VARPTR(FWord), dm_Default+32, 2
       SHOWMESSAGE("DevMode - Specification Version: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+34, 2
       SHOWMESSAGE("DevMode - Driver Version: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+36, 2
       SHOWMESSAGE("DevMode - dmSize: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+38, 2
       SHOWMESSAGE("DevMode - Driver Extra Size: "+STR$(FWord))
       CopyMemory VARPTR(FFour), dm_Default+40, 4
       SHOWMESSAGE("DevMode - Fields: "+STR$(FFour))
       CopyMemory VARPTR(FWord), dm_Default+44, 2
       SHOWMESSAGE("DevMode - Orientation: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+46, 2
       SHOWMESSAGE("DevMode - Paper Size: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+48, 2
       SHOWMESSAGE("DevMode - Paper Length: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+50, 2
       SHOWMESSAGE("DevMode - Paper Width: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+52, 2
       SHOWMESSAGE("DevMode - Scale: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+54, 2
       SHOWMESSAGE("DevMode - Copies: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+56, 2
       SHOWMESSAGE("DevMode - Bins: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+58, 2
       SHOWMESSAGE("DevMode - Quality: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+60, 2
       SHOWMESSAGE("DevMode - Colour: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+62, 2
       SHOWMESSAGE("DevMode - Duplex: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+64, 2
       SHOWMESSAGE("DevMode - YResolution: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+66, 2
       SHOWMESSAGE("DevMode - TrueType Option: "+STR$(FWord))
       CopyMemory VARPTR(FWord), dm_Default+70, 2
       SHOWMESSAGE("DevMode - Collate: "+STR$(FWord))

' 72 DeviceName - 30 characters stored here (not a pointer).

       CopyMemory VARPTR(FWord), dm_Default+102, 2
       SHOWMESSAGE("DevMode - LogicalPixels: "+STR$(FWord))
       CopyMemory VARPTR(FFour), dm_Default+104, 4
       SHOWMESSAGE("DevMode - BitsPerPixel: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+108, 4
       SHOWMESSAGE("DevMode - PixelWidth: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+112, 4
       SHOWMESSAGE("DevMode - PixelHeight: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+116, 4
       SHOWMESSAGE("DevMode - DisplayFlags: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+120, 4
       SHOWMESSAGE("DevMode - DisplayFrequency: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+124, 4
       SHOWMESSAGE("DevMode - ICMMethod: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+128, 4
       SHOWMESSAGE("DevMode - ICMIntent: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+132, 4
       SHOWMESSAGE("DevMode - MediaType: "+STR$(FFour))
       CopyMemory VARPTR(FFour), dm_Default+136, 4
       SHOWMESSAGE("DevMode - DitherType: "+STR$(FFour))

' 140 and 144 are reserved.
      END IF
     END SUB

     SUB Show_PI2
      IF ((prt_opened=1) AND (pi2_mem=1)) THEN
       CopyMemory VARPTR(FAdr), pi2_Default, 4
       SHOWMESSAGE("PI2 - ServerName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+4, 4
       SHOWMESSAGE("PI2 - PrinterName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+8, 4
       SHOWMESSAGE("PI2 - ShareName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+12, 4
       SHOWMESSAGE("PI2 - PortName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+16, 4
       SHOWMESSAGE("PI2 - DriverName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+20, 4
       SHOWMESSAGE("PI2 - Comment: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+24, 4
       SHOWMESSAGE("PI2 - Location: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+32, 4
       SHOWMESSAGE("PI2 - Seperator File: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+36, 4
       SHOWMESSAGE("PI2 - PrintProcessor: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+40, 4
       SHOWMESSAGE("PI2 - DataType: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+44, 4
       SHOWMESSAGE("PI2 - Parameters: "+VARPTR$(FAdr))
' 48 SECURITY DESCRIPTOR
       CopyMemory VARPTR(FAdr), pi2_Default+52, 4
       SHOWMESSAGE("PI2 - Attributes: "+STR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+56, 4
       SHOWMESSAGE("PI2 - Priority: "+STR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+60, 4
       SHOWMESSAGE("PI2 - Default Priority: "+STR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+64, 4
       SHOWMESSAGE("PI2 - Start Time: "+STR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+68, 4
       SHOWMESSAGE("PI2 - Until Time: "+STR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+72, 4
       SHOWMESSAGE("PI2 - Status: "+STR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+76, 4
       SHOWMESSAGE("PI2 - Jobs: "+STR$(FAdr))
       CopyMemory VARPTR(FAdr), pi2_Default+80, 4
       SHOWMESSAGE("PI2 - AveragePPM: "+STR$(FAdr))

       SHOWMESSAGE("DevMode - DeviceName: "+VARPTR$(pi2_Default+96))
       CopyMemory VARPTR(FWord), pi2_Default+128, 2
       SHOWMESSAGE("DevMode - Specification Version: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+130, 2
       SHOWMESSAGE("DevMode - Driver Version: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+132, 2
       SHOWMESSAGE("DevMode - dmSize: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+134, 2
       SHOWMESSAGE("DevMode - Driver Extra Size: "+STR$(FWord))
       CopyMemory VARPTR(FFour), pi2_Default+136, 4
       SHOWMESSAGE("DevMode - Fields: "+STR$(FFour))
       CopyMemory VARPTR(FWord), pi2_Default+140, 2
       SHOWMESSAGE("DevMode - Orientation: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+142, 2
       SHOWMESSAGE("DevMode - Paper Size: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+144, 2
       SHOWMESSAGE("DevMode - Paper Length: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+146, 2
       SHOWMESSAGE("DevMode - Paper Width: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+148, 2
       SHOWMESSAGE("DevMode - Scale: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+150, 2
       SHOWMESSAGE("DevMode - Copies: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+152, 2
       SHOWMESSAGE("DevMode - Bins: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+154, 2
       SHOWMESSAGE("DevMode - Quality: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+156, 2
       SHOWMESSAGE("DevMode - Colour: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+158, 2
       SHOWMESSAGE("DevMode - Duplex: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+160, 2
       SHOWMESSAGE("DevMode - YResolution: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+162, 2
       SHOWMESSAGE("DevMode - TrueType Option: "+STR$(FWord))
       CopyMemory VARPTR(FWord), pi2_Default+166, 2
       SHOWMESSAGE("DevMode - Collate: "+STR$(FWord))

' 168 DeviceName - 30 characters stored here (not a pointer).

       CopyMemory VARPTR(FWord), pi2_Default+198, 2
       SHOWMESSAGE("DevMode - LogicalPixels: "+STR$(FWord))
       CopyMemory VARPTR(FFour), pi2_Default+200, 4
       SHOWMESSAGE("DevMode - BitsPerPixel: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+204, 4
       SHOWMESSAGE("DevMode - PixelWidth: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+208, 4
       SHOWMESSAGE("DevMode - PixelHeight: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+212, 4
       SHOWMESSAGE("DevMode - DisplayFlags: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+216, 4
       SHOWMESSAGE("DevMode - DisplayFrequency: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+220, 4
       SHOWMESSAGE("DevMode - ICMMethod: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+224, 4
       SHOWMESSAGE("DevMode - ICMIntent: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+228, 4
       SHOWMESSAGE("DevMode - MediaType: "+STR$(FFour))
       CopyMemory VARPTR(FFour), pi2_Default+232, 4
       SHOWMESSAGE("DevMode - DitherType: "+STR$(FFour))

' 236 and 240 are reserved.
      END IF
     END SUB

     SUB Show_Jobs
      IF ((prt_opened=1) AND (jobs_mem=1)) THEN
       CopyMemory VARPTR(FFour), jobs_Default, 4
       SHOWMESSAGE("GJ - JobID: "+STR$(FFour))
       CopyMemory VARPTR(FAdr), jobs_Default+4, 4
       SHOWMESSAGE("GJ - PrinterName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+8, 4
       SHOWMESSAGE("GJ - MachineName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+12, 4
       SHOWMESSAGE("GJ - UserName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+16, 4
       SHOWMESSAGE("GJ - DocumentName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+20, 4
       SHOWMESSAGE("GJ - NotifyName: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+24, 4
       SHOWMESSAGE("GJ - DataType: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+28, 4
       SHOWMESSAGE("GJ - PrintProcessor: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+32, 4
       SHOWMESSAGE("GJ - Parameters: "+VARPTR$(FAdr))
       CopyMemory VARPTR(FAdr), jobs_Default+36, 4
       SHOWMESSAGE("GJ - DriverName: "+VARPTR$(FAdr))

' jobs_Default+40 = pointer to DevMode.

       CopyMemory VARPTR(FAdr), jobs_Default+44, 4
       SHOWMESSAGE("GJ - Status String: "+VARPTR$(FAdr))

' jobs_Default+48 = pointer to Security Descriptor.

       CopyMemory VARPTR(FFour), jobs_Default+52, 4
       SHOWMESSAGE("GJ - Status DWORD: "+HEX$(FFour))
       CopyMemory VARPTR(FFour), jobs_Default+56, 4
       SHOWMESSAGE("GJ - Priority: "+HEX$(FFour))
       CopyMemory VARPTR(FFour), jobs_Default+60, 4
       SHOWMESSAGE("GJ - Position: "+HEX$(FFour))
       CopyMemory VARPTR(FFour), jobs_Default+64, 4
       SHOWMESSAGE("GJ - Start Time: "+HEX$(FFour))
       CopyMemory VARPTR(FFour), jobs_Default+68, 4
       SHOWMESSAGE("GJ - Until Time: "+HEX$(FFour))
       CopyMemory VARPTR(FFour), jobs_Default+72, 4
       SHOWMESSAGE("GJ - Total Pages: "+HEX$(FFour))
       CopyMemory VARPTR(FFour), jobs_Default+76, 4
       SHOWMESSAGE("GJ - Size: "+HEX$(FFour))

' SystemTime Structure - Time the documented started printing.
       CopyMemory VARPTR(FWord), jobs_Default+80, 2
       SHOWMESSAGE("GJ - Year: "+STR$(FWord))
       CopyMemory VARPTR(FWord), jobs_Default+82, 2
       SHOWMESSAGE("GJ - Month: "+STR$(FWord))
       CopyMemory VARPTR(FWord), jobs_Default+84, 2
       SHOWMESSAGE("GJ - Day Of The Week: "+STR$(FWord+1))
       CopyMemory VARPTR(FWord), jobs_Default+86, 2
       SHOWMESSAGE("GJ - Day: "+STR$(FWord))
       CopyMemory VARPTR(FWord), jobs_Default+88, 2
       SHOWMESSAGE("GJ - Hour: "+STR$(FWord+1))
       CopyMemory VARPTR(FWord), jobs_Default+90, 2
       SHOWMESSAGE("GJ - Minute: "+STR$(FWord))
       CopyMemory VARPTR(FWord), jobs_Default+92, 2
       SHOWMESSAGE("GJ - Seconds: "+STR$(FWord))
       CopyMemory VARPTR(FWord), jobs_Default+94, 2
       SHOWMESSAGE("GJ - MilliSeconds: "+STR$(FWord))

       CopyMemory VARPTR(FFour), jobs_Default+96, 4
       SHOWMESSAGE("GJ - Time: "+HEX$(FFour))
       CopyMemory VARPTR(FFour), jobs_Default+100, 4
       SHOWMESSAGE("GJ - Pages Printed: "+HEX$(FFour))

' The next jobs is at 104 - Example....
'CopyMemory VarPtr(FFour), jobs_Default+104, 4
'showmessage("GJ - JobID: "+str$(FFour))
'CopyMemory VarPtr(FAdr), jobs_Default+108, 4
'showmessage("GJ - PrinterName: "+Varptr$(FAdr))
' ......
' Etc Etc

      END IF
     END SUB

     SUB Free_dmMemory
      IF dm_mem=1 THEN
       rtn=GlobalUnlock(dmLock)
       IF ((rtn=0) AND (GetLastError()=0)) THEN
'MEM UNLOCKED
       ELSE
'MEM NOT UNLOCK
       END IF
       rtn=GlobalFree(dm_Memory)
       IF rtn=0 THEN
'MEM FREED
        dm_mem=0
       ELSE
'MEM NOT FREED
       END IF
      END IF
     END SUB

     SUB Free_pi2Memory
      IF pi2_mem=1 THEN
       rtn=GlobalUnlock(pi2Lock)
       IF ((rtn=0) AND (GetLastError()=0)) THEN
'MEM UNLOCKED
       ELSE
'MEM NOT UNLOCK
       END IF
       rtn=GlobalFree(pi2_Memory)
       IF rtn=0 THEN
'MEM FREED
        pi2_mem=0
       ELSE
'MEM NOT FREED
       END IF
      END IF
     END SUB

     SUB Free_jobsMemory
      IF jobs_mem=1 THEN
       rtn=GlobalUnlock(jobs_Lock)
       IF ((rtn=0) AND (GetLastError()=0)) THEN
'MEM UNLOCKED
       ELSE
'MEM NOT UNLOCK
       END IF
       rtn=GlobalFree(jobs_Memory)
       IF rtn=0 THEN
'MEM FREED
        jobs_mem=0
       ELSE
'MEM NOT FREED
       END IF
      END IF
     END SUB

     SUB Free_jobMemory
      IF job_mem=1 THEN
       rtn=GlobalUnlock(job_Lock)
       IF ((rtn=0) AND (GetLastError()=0)) THEN
'MEM UNLOCKED
       ELSE
'MEM NOT UNLOCK
       END IF
       rtn=GlobalFree(job_Memory)
       IF rtn=0 THEN
'MEM FREED
        job_mem=0
       ELSE
'MEM NOT FREED
       END IF
      END IF
     END SUB

     SUB UnLock_DefaultMemory
      rtn=GlobalUnlock(FLock)
      IF ((rtn=0) AND (GetLastError()=0)) THEN
'MEM UNLOCKED
      ELSE
'MEM NOT UNLOCK
      END IF
     END SUB

     SUB Free_DefaultMemory
      rtn=GlobalFree(FLong)
      IF rtn=0 THEN
'MEM FREED
      ELSE
'MEM NOT FREED
      END IF
     END SUB

     SUB Free_pdMemory
      IF pd_mem=1 THEN
       rtn=GlobalUnlock(pd_Lock)
       IF ((rtn=0) AND (GetLastError()=0)) THEN
'PD_MEM UNLOCKED
       ELSE
'PD_MEM NOT UNLOCK
       END IF
       rtn=GlobalFree(pd_Memory)
       IF rtn=0 THEN
'PD_MEM FREED
       ELSE
'PD_MEM NOT FREED
       END IF
      END IF
     END SUB

     SUB Set_Orientation(landscape AS WORD, setFlag AS BYTE)
      FWord=landscape
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+44, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+140, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+44, VARPTR(FWord), 2
       CopyMemory pi2_Default+140, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_PaperSize(papersize AS WORD, setFlag AS BYTE)
      FWord=papersize
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+46, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+142, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+46, VARPTR(FWord), 2
       CopyMemory pi2_Default+142, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_PaperLength(paperlength AS WORD, setFlag AS BYTE)
      FWord=paperlength
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+48, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+144, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+48, VARPTR(FWord), 2
       CopyMemory pi2_Default+144, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_PaperWidth(paperwidth AS WORD, setFlag AS BYTE)
      FWord=paperwidth
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+50, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+146, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+50, VARPTR(FWord), 2
       CopyMemory pi2_Default+146, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_Scale(scaleFactor AS WORD, setFlag AS BYTE)
      FWord=scaleFactor
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+52, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+148, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+52, VARPTR(FWord), 2
       CopyMemory pi2_Default+148, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_Copies(numCopies AS WORD, setFlag AS BYTE)
      FWord=numCopies
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+54, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+150, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+54, VARPTR(FWord), 2
       CopyMemory pi2_Default+150, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_PaperFeed(bin AS WORD, setFlag AS BYTE)
      FWord=bin
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+56, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+152, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+56, VARPTR(FWord), 2
       CopyMemory pi2_Default+152, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_PrintQuality(quality AS WORD, setFlag AS BYTE)
      FWord=quality
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+58, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+154, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+58, VARPTR(FWord), 2
       CopyMemory pi2_Default+154, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_ColourMode(mode AS WORD, setFlag AS BYTE)
      FWord=mode
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+60, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+156, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+60, VARPTR(FWord), 2
       CopyMemory pi2_Default+156, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_Duplex(mode AS WORD, setFlag AS BYTE)
      FWord=mode
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+62, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+158, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+62, VARPTR(FWord), 2
       CopyMemory pi2_Default+158, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_YResolution(yDPI AS WORD, setFlag AS BYTE)
      FWord=yDPI
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+64, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+160, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+64, VARPTR(FWord), 2
       CopyMemory pi2_Default+160, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_TTOption(OPTION AS WORD, setFlag AS BYTE)
      FWord=OPTION
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+66, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+162, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+66, VARPTR(FWord), 2
       CopyMemory pi2_Default+162, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_Collate(OPTION AS WORD, setFlag AS BYTE)
      FWord=OPTION
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+70, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+166, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+70, VARPTR(FWord), 2
       CopyMemory pi2_Default+166, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_PixelsPerLogicalInch(numPixels AS WORD, setFlag AS BYTE)
      FWord=numPixels
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+102, VARPTR(FWord), 2
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+198, VARPTR(FWord), 2
      ELSE
       CopyMemory dm_Default+102, VARPTR(FWord), 2
       CopyMemory pi2_Default+198, VARPTR(FWord), 2
      END IF
     END SUB

     SUB Set_ICMMethod(method AS LONG, setFlag AS BYTE)
      FFour=method
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+124, VARPTR(FFour), 4
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+220, VARPTR(FFour), 4
      ELSE
       CopyMemory dm_Default+124, VARPTR(FFour), 4
       CopyMemory pi2_Default+220, VARPTR(FFour), 4
      END IF
     END SUB

     SUB Set_ICMIntent(intent AS LONG, setFlag AS BYTE)
      FFour=intent
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+128, VARPTR(FFour), 4
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+224, VARPTR(FFour), 4
      ELSE
       CopyMemory dm_Default+128, VARPTR(FFour), 4
       CopyMemory pi2_Default+224, VARPTR(FFour), 4
      END IF
     END SUB

     SUB Set_MediaType(mediaType AS LONG, setFlag AS BYTE)
      FFour=mediaType
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+132, VARPTR(FFour), 4
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+228, VARPTR(FFour), 4
      ELSE
       CopyMemory dm_Default+132, VARPTR(FFour), 4
       CopyMemory pi2_Default+228, VARPTR(FFour), 4
      END IF
     END SUB

     SUB Set_DitherType(dither AS LONG, setFlag AS BYTE)
      FFour=dither
      IF setFlag=SET_DDM THEN
       CopyMemory dm_Default+136, VARPTR(FFour), 4
      ELSEIF setFlag=SET_PI2DM THEN
       CopyMemory pi2_Default+232, VARPTR(FFour), 4
      ELSE
       CopyMemory dm_Default+136, VARPTR(FFour), 4
       CopyMemory pi2_Default+232, VARPTR(FFour), 4
      END IF
     END SUB

     SUB Set_ServerName(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_PrinterName(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+4, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_ShareName(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+8, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_PortName(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+12, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_DriverName(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+16, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_Location(location$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+24, 4
      stg$=location$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_SeperatorFile(sfile$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+32, 4
      stg$=sfile$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_PrintProcessor(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+36, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_DataType(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+40, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Set_Parameters(name$ AS STRING)
      CopyMemory VARPTR(FAdr), pi2_Default+44, 4
      stg$=name$+CHR$(0)
      CopyMemory FAdr, VARPTR(stg$), LEN(stg$)
     END SUB

     SUB Advanced_Document_Properties
      IF prt_opened=1 THEN
       rtn=AdvancedDocumentProperties(0, prt_Handle, device_Name$, dm_Default, dm_Default)
       IF rtn=1 THEN

       END IF
      END IF
     END SUB

     SUB Properties_Window
      IF prt_opened=1 THEN
       rtn=PrinterProperties(0, prt_Handle)
       IF rtn<>0 THEN

       END IF
      END IF
     END SUB

     SUB Configure_Port(serverAdr AS LONG, portAdr AS LONG)
      IF prt_opened=1 THEN
       rtn=ConfigurePort(serverAdr, 0, portAdr)
       IF rtn<>0 THEN

       END IF
      END IF
     END SUB

     SUB Document_Properties
      IF prt_opened=1 THEN
       rtn=DocumentProperties(0, prt_Handle, device_Name$, dm_Default, dm_Default, DM_MODIFY OR DM_PROMPT OR DM_COPY)
       IF rtn>-1 THEN
        IF rtn=IDOK THEN
         SHOWMESSAGE("User Pressed: OKAY or Exit")
        ELSEIF rtn=IDCANCEL THEN
         SHOWMESSAGE("User Pressed: CANCEL")
        END IF
       END IF
      END IF
     END SUB

     SUB PageSetupDialog
      IF prt_opened=1 THEN
       FLong=GlobalAlloc(GMEM_MOVEABLE OR GMEM_ZEROINIT, 3000)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt
         FFour=84
         CopyMemory FInt, VARPTR(FFour), 4
         FFour=PD_RETURNDEFAULT
         CopyMemory FInt+16, VARPTR(FFour), 4
         rtn=PageSetupDlg(FInt)
         IF rtn<>0 THEN

' Note: Here I have disabled most options as you can get/set them from
' other features in this code. Also. This dialog does not initialize
' the devmode - it just utilizes certain values from the computer`s
' default printer. Although it returns a global pointer to a DevMode
' this is not neccessarily a valid devmode (depending on user input).
' Therefore. Just use this dialog to setup (calculate) the Margins only.
'
' Personally, if it wasn`t for the Margins feature, I wouldn`t use
' this dialogat all.

' Flags
          FFour=PSD_INTHOUSANDTHSOFINCHES OR PSD_MINMARGINS OR PSD_MARGINS OR PSD_DISABLEORIENTATION OR PSD_DISABLEPRINTER OR PSD_DISABLEPAPER
          CopyMemory FInt+16, VARPTR(FFour), 4

' Paper Size  -  These two values are really for the callback hook with
' WM_PSD_PAGESETUPDLG. Ignore them.
          FFour=0
          CopyMemory FInt+20, VARPTR(FFour), 4
          FFour=0
          CopyMemory FInt+24, VARPTR(FFour), 4

' 1000`s of an Inch. 1000 = 1 Inch. Below I use an half-inch (0.5)
' margin as the minimum the user can specify.
'
' You will not get an error if user specifies less than
' 500 (0.5 / half-inch) but the return will be 500, as default, in
' this case.

' Minimum values for the Margins
          FFour=500
          CopyMemory FInt+28, VARPTR(FFour), 4
          FFour=500
          CopyMemory FInt+32, VARPTR(FFour), 4
          FFour=500
          CopyMemory FInt+36, VARPTR(FFour), 4
          FFour=500
          CopyMemory FInt+40, VARPTR(FFour), 4

' Maximum values for the Margins  -  The max margins I have set below
' are 1 inch (left), 1.5 inch (top), 1.5 inch (right) and 1 inch (bottom).
          FFour=1000
          CopyMemory FInt+44, VARPTR(FFour), 4
          FFour=1250
          CopyMemory FInt+48, VARPTR(FFour), 4
          FFour=1250
          CopyMemory FInt+52, VARPTR(FFour), 4
          FFour=1000
          CopyMemory FInt+56, VARPTR(FFour), 4

          rtn=PageSetupDlg(FInt)
          IF rtn=1 THEN

' Show the user`s minimum margin settings.
           CopyMemory VARPTR(FFour), FInt+28, 4
           SHOWMESSAGE(STR$(FFour))
           CopyMemory VARPTR(FFour), FInt+32, 4
           SHOWMESSAGE(STR$(FFour))
           CopyMemory VARPTR(FFour), FInt+36, 4
           SHOWMESSAGE(STR$(FFour))
           CopyMemory VARPTR(FFour), FInt+40, 4
           SHOWMESSAGE(STR$(FFour))

' Show the user`s maximum margin settings.
           CopyMemory VARPTR(FFour), FInt+44, 4
           SHOWMESSAGE(STR$(FFour))
           CopyMemory VARPTR(FFour), FInt+48, 4
           SHOWMESSAGE(STR$(FFour))
           CopyMemory VARPTR(FFour), FInt+52, 4
           SHOWMESSAGE(STR$(FFour))
           CopyMemory VARPTR(FFour), FInt+56, 4
           SHOWMESSAGE(STR$(FFour))

          ELSEIF rtn=0 THEN

' User pressed Cancel or there was an error.

          ELSE
           rtn=CommDlgExtendedError
           SHOWMESSAGE(HEX$(rtn))
          END IF
         ELSE
          rtn=CommDlgExtendedError
          SHOWMESSAGE(HEX$(rtn))
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Print_Dialog
      IF prt_opened=1 THEN
       FLong=GlobalAlloc(GMEM_MOVEABLE OR GMEM_ZEROINIT, 3000)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt
         FFour=66
         CopyMemory FInt, VARPTR(FFour), 4
         FFour=PD_RETURNDEFAULT OR PD_RETURNDC
         CopyMemory FInt+20, VARPTR(FFour), 4
         rtn=PrintDlg(FInt)
         IF rtn=1 THEN

' The PrintDlg works on a Input/Output basis. This means what you
' initialize (setup) for the user/Dialog is known as the Input. And
' what the dialog returns is known as the Output.
'
' The following is a case of mix `n` match to suit your particular
' Printer. For example:
'
' PD_USEDEVMODECOPIESANDCOLLATE should be used to use your real printer
' settings. This will disable/hide the Copies and Collate buttons if
' they are not supported by your printer driver. This is true of my
' Epson RX-80. In this case you go by the number-of-pages to print
' rather than the number of copies. This just said scenario can be over
' ridden by not specify USEDEVMODECOPIESANDCOLLATE and specifying
' PD_SELECTION OR PD_COLLATE instead. If you do not use the
' USEDEVMODECOPIESANDCOLLATE flag though the copies and collate result
' goes into the devmode (devmode pointer).
'
' Flags:  PD_SELECTION means selection button is default
'         PD_PAGENUMS ......    pages   ................
'         PD_ALLPAGES ......     all    ................
' If none are selected then ALL is the default.
'
' PRINTOTFILE means Print to the FILE: port.

          FFour=PD_SELECTION OR PD_COLLATE OR PD_PAGENUMS OR PD_PRINTTOFILE
          CopyMemory FInt+20, VARPTR(FFour), 4
          FWord=1 ' from page
          CopyMemory FInt+24, VARPTR(FWord), 2
          FWord=6 ' to page
          CopyMemory FInt+26, VARPTR(FWord), 2
          FWord=1  ' minimum range for the pages
          CopyMemory FInt+28, VARPTR(FWord), 2
          FWord=9  ' maximum range for the pages
          CopyMemory FInt+30, VARPTR(FWord), 2
          FWord=4  ' number of copies to print
          CopyMemory FInt+32, VARPTR(FWord), 2
          rtn=PrintDlg(FInt)
          IF rtn=1 THEN

' show the flags value. If collate is set it means collate is not
' supported (like on my Epson RX-80).
           CopyMemory VARPTR(FFour), FInt+20, 4
           SHOWMESSAGE(HEX$(FFour))

' show the min. page and max. page the user specified.
           CopyMemory VARPTR(FWord), FInt+24, 2
           SHOWMESSAGE(HEX$(FWord))
           CopyMemory VARPTR(FWord), FInt+26, 2
           SHOWMESSAGE(HEX$(FWord))

' show the number of copies to print that the user specified.
           CopyMemory VARPTR(FWord), FInt+32, 2
           SHOWMESSAGE(HEX$(FWord))

          ELSEIF rtn=0 THEN

' User pressed Cancel or there was an error.

          ELSE
           rtn=CommDlgExtendedError
           SHOWMESSAGE(HEX$(rtn))
          END IF
         ELSE
          rtn=CommDlgExtendedError
          SHOWMESSAGE(HEX$(rtn))
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Enum_Ports(serverName AS STRING, level AS LONG)
      prt_error=1
      rtn=EnumPorts(serverName, level, 0, 0, @needed, @rtnval)
      IF ((rtn=0) AND (GetLastError()=ERROR_INSUFFICIENT_BUFFER)) THEN
       FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, needed)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt
         rtn=EnumPorts(serverName, level, FInt, needed, @needed, @rtnval)
         IF rtn=1 THEN
          prt_error=0
          FOR count=0 TO rtnval-1
           IF level=1 THEN
            CopyMemory VARPTR(ports(count)), FInt, 4
            INC (FInt, 4)
           ELSE
            CopyMemory VARPTR(ports((0+(count*5)))), FInt, 4
            CopyMemory VARPTR(ports((1+(count*5)))), FInt+4, 4
            CopyMemory VARPTR(ports((2+(count*5)))), FInt+8, 4
            CopyMemory VARPTR(ports((3+(count*5)))), FInt+12, 4
            CopyMemory VARPTR(ports((4+(count*5)))), FInt+16, 4
            INC (FInt, 20)
           END IF
          NEXT
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Enum_Drivers(serverName AS STRING, level AS LONG)
      prt_error=1
      rtn=EnumPrinterDrivers(serverName, 0, level, 0, 0, @needed, @rtnval)
      IF ((rtn=0) AND (GetLastError()=ERROR_INSUFFICIENT_BUFFER)) THEN
       FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, needed)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt
         rtn=EnumPrinterDrivers(serverName, 0, level, FInt, needed, @needed, @rtnval)
         IF rtn=1 THEN
          prt_error=0
          FOR count=0 TO rtnval-1
           IF level=1 THEN
            CopyMemory VARPTR(drivers(count)), FInt, 4
            INC (FInt, 4)
           ELSEIF level=2 THEN
            CopyMemory VARPTR(drivers((0+(count*6)))), FInt, 4
            CopyMemory VARPTR(drivers((1+(count*6)))), FInt+4, 4
            CopyMemory VARPTR(drivers((2+(count*6)))), FInt+8, 4
            CopyMemory VARPTR(drivers((3+(count*6)))), FInt+12, 4
            CopyMemory VARPTR(drivers((4+(count*6)))), FInt+16, 4
            CopyMemory VARPTR(drivers((5+(count*6)))), FInt+20, 4
            INC (FInt, 24)
           ELSE
            CopyMemory VARPTR(drivers((0+(count*10)))), FInt, 4
            CopyMemory VARPTR(drivers((1+(count*10)))), FInt+4, 4
            CopyMemory VARPTR(drivers((2+(count*10)))), FInt+8, 4
            CopyMemory VARPTR(drivers((3+(count*10)))), FInt+12, 4
            CopyMemory VARPTR(drivers((4+(count*10)))), FInt+16, 4
            CopyMemory VARPTR(drivers((5+(count*10)))), FInt+20, 4
            CopyMemory VARPTR(drivers((6+(count*10)))), FInt+24, 4
            CopyMemory VARPTR(drivers((7+(count*10)))), FInt+28, 4
            CopyMemory VARPTR(drivers((8+(count*10)))), FInt+32, 4
            CopyMemory VARPTR(drivers((9+(count*10)))), FInt+36, 4
            INC (FInt, 40)
           END IF
          NEXT
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Enum_Printers(flag AS LONG, name AS STRING, level AS LONG, get_default AS BYTE, default_printer$ AS STRING, default_port$ AS STRING)
      prt_error=1
      rtn=EnumPrinters(flag, name, level, 0, 0, @needed, @rtnval)
      IF ((rtn=0) AND (GetLastError()=ERROR_INSUFFICIENT_BUFFER)) THEN
       FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, needed)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt
         rtn=EnumPrinters(flag, name, level, FInt, needed, @needed, @rtnval)
         IF rtn=1 THEN
          IF get_Default=0 THEN
           prt_error=0
           FOR count=0 TO rtnval-1
            IF level=1 THEN
             CopyMemory VARPTR(printers((0+(count*4)))), FInt, 4
             CopyMemory VARPTR(printers((1+(count*4)))), FInt+4, 4
             CopyMemory VARPTR(printers((2+(count*4)))), FInt+8, 4
             CopyMemory VARPTR(printers((3+(count*4)))), FInt+12, 4
             INC (FInt, 16)
            ELSEIF level=2 THEN

            ELSEIF level=4 THEN
             CopyMemory VARPTR(printers((0+(count*3)))), FInt, 4
             CopyMemory VARPTR(printers((1+(count*3)))), FInt+4, 4
             CopyMemory VARPTR(printers((2+(count*3)))), FInt+8, 4
             INC (FInt, 12)
            ELSEIF level=5 THEN
             CopyMemory VARPTR(printers((0+(count*5)))), FInt, 4
             CopyMemory VARPTR(printers((1+(count*5)))), FInt+4, 4
             CopyMemory VARPTR(printers((2+(count*5)))), FInt+8, 4
             CopyMemory VARPTR(printers((3+(count*5)))), FInt+12, 4
             CopyMemory VARPTR(printers((4+(count*5)))), FInt+16, 4
             INC (FInt, 20)
            END IF
           NEXT
          ELSE
' check the Attributes element/field to get the Default Printer.
           count=0
           WHILE ((count<rtnval) AND (prt_error=1))
            CopyMemory VARPTR(FFour), FInt+8, 4
            IF (FFour AND PRINTER_ATTRIBUTE_DEFAULT)=PRINTER_ATTRIBUTE_DEFAULT THEN
             prt_error=0
' Copy the printer name into prt_Name$ string.
             CopyMemory VARPTR(FAdr), FInt, 4
             FLen=LEN(VARPTR$(FAdr))
             prt_Name$=STRING$(FLen, 0)
             CopyMemory VARPTR(prt_Name$), FAdr, FLen
' Copy the port name into prt_Port$ string.
             CopyMemory VARPTR(FAdr), FInt+4, 4
             FLen=LEN(VARPTR$(FAdr))
             prt_Port$=STRING$(FLen, 0)
             CopyMemory VARPTR(prt_Port$), FAdr, FLen
            END IF
            INC (FInt, 20)
            INC count
           WEND
           IF prt_error=1 THEN
' Could not get Default Printer - So use a default printer-driver instead.
            prt_error=0
            prt_Name$=default_printer$
            prt_Port$=default_port$
           END IF
           SHOWMESSAGE("Default Printer: "+prt_Name$+"\n\nDefault Port: "+prt_Port$)
          END IF
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Create_DC()
' The Printer Device Context tells the computer what your Printer is
' capable of doing (Printing Circles, Using Fonts, Pens, etc). When you
' want to change the Printer`s pen for example you pass it this pointer.
      prt_error=1
      prt_DC=0
      prt_DC=CreateDC("", prt_Name$, "", 0)
      IF prt_DC<>0 THEN
       prt_error=0

      ELSE
       SHOWMESSAGE("DC - Not Created")
      END IF
     END SUB

     SUB Open_Printer()
      prt_opened=0
      prt_error=1
      pDefault(0)=""
      pDefault(1)=0
      pDefault(2)=PRINTER_ACCESS_ADMINISTER OR PRINTER_ACCESS_USE OR STANDARD_RIGHTS_REQUIRED
      rtn=OpenPrinter(prt_Name$, @prt_Handle, @pd_Default)
      IF rtn<>0 THEN
       prt_opened=1
       prt_error=0

      ELSE
       SHOWMESSAGE("Printer - Not Opened")
      END IF
     END SUB

     SUB Get_Driver(environment AS STRING, level AS LONG)
      prt_error=1
      IF prt_opened=1 THEN
       rtn=GetPrinterDriver(prt_Handle, environment, level, 0, 0, @needed)
       IF ((rtn=0) AND (GetLastError()=ERROR_INSUFFICIENT_BUFFER)) THEN
        FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, needed)
        IF FLong<>0 THEN
         FInt=GlobalLock(FLong)
         IF FInt<>0 THEN
          FLock=FInt
          rtn=GetPrinterDriver(prt_Handle, environment, level, FInt, needed, @needed)
          IF rtn=1 THEN
           prt_error=0
           IF level=1 THEN
            CopyMemory VARPTR(drivers(count)), FInt, 4
            INC (FInt, 4)
           ELSEIF level=2 THEN
            CopyMemory VARPTR(drivers((0+(count*6)))), FInt, 4
            CopyMemory VARPTR(drivers((1+(count*6)))), FInt+4, 4
            CopyMemory VARPTR(drivers((2+(count*6)))), FInt+8, 4
            CopyMemory VARPTR(drivers((3+(count*6)))), FInt+12, 4
            CopyMemory VARPTR(drivers((4+(count*6)))), FInt+16, 4
            CopyMemory VARPTR(drivers((5+(count*6)))), FInt+20, 4
            INC (FInt, 24)
           ELSE
            CopyMemory VARPTR(drivers((0+(count*10)))), FInt, 4
            CopyMemory VARPTR(drivers((1+(count*10)))), FInt+4, 4
            CopyMemory VARPTR(drivers((2+(count*10)))), FInt+8, 4
            CopyMemory VARPTR(drivers((3+(count*10)))), FInt+12, 4
            CopyMemory VARPTR(drivers((4+(count*10)))), FInt+16, 4
            CopyMemory VARPTR(drivers((5+(count*10)))), FInt+20, 4
            CopyMemory VARPTR(drivers((6+(count*10)))), FInt+24, 4
            CopyMemory VARPTR(drivers((7+(count*10)))), FInt+28, 4
            CopyMemory VARPTR(drivers((8+(count*10)))), FInt+32, 4
            CopyMemory VARPTR(drivers((9+(count*10)))), FInt+36, 4
            INC (FInt, 40)
           END IF
          END IF
          UnLock_DefaultMemory
         END IF
         Free_DefaultMemory
        END IF
       END IF
      END IF
     END SUB

     SUB Get_PI2
      pi2_mem=0
      pi2_DevMode=0
      prt_error=1
      IF prt_opened=1 THEN
       rtn=GetPrinter(prt_Handle, 2, 0, 0, @needed)
       IF ((rtn=0) AND (GetLastError()=ERROR_INSUFFICIENT_BUFFER)) THEN
        pi2_Memory=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, needed)
        IF pi2_Memory<>0 THEN
         pi2_mem=1
         pi2_Default=GlobalLock(pi2_Memory)
         IF pi2_Default<>0 THEN
          pi2Lock=pi2_Default
          rtn=GetPrinter(prt_Handle, 2, pi2_Default, needed, @rtnval)
          IF rtn=1 THEN
           CopyMemory VARPTR(pi2_DevMode), pi2_Default+28, 4
           IF pi2_DevMode<>0 THEN  ' Check for a valid DEVMODE structure
            prt_error=0

           END IF
          END IF
         END IF
        END IF
       END IF
      END IF
     END SUB

     SUB Copy_DevMode(flag AS BYTE)
      IF flag=0 THEN
       CopyMemory pi2_Default+128, dm_Default+32, 2
       CopyMemory pi2_Default+130, dm_Default+34, 2
       CopyMemory pi2_Default+132, dm_Default+36, 2
       CopyMemory pi2_Default+134, dm_Default+38, 2
       CopyMemory pi2_Default+136, dm_Default+40, 4
       CopyMemory pi2_Default+140, dm_Default+44, 2
       CopyMemory pi2_Default+142, dm_Default+46, 2
       CopyMemory pi2_Default+144, dm_Default+48, 2
       CopyMemory pi2_Default+146, dm_Default+50, 2
       CopyMemory pi2_Default+148, dm_Default+52, 2
       CopyMemory pi2_Default+150, dm_Default+54, 2
       CopyMemory pi2_Default+152, dm_Default+56, 2
       CopyMemory pi2_Default+154, dm_Default+58, 2
       CopyMemory pi2_Default+156, dm_Default+60, 2
       CopyMemory pi2_Default+158, dm_Default+62, 2
       CopyMemory pi2_Default+160, dm_Default+64, 2
       CopyMemory pi2_Default+162, dm_Default+66, 2
       CopyMemory pi2_Default+164, dm_Default+68, 2

       CopyMemory pi2_Default+198, dm_Default+102, 2
       CopyMemory pi2_Default+200, dm_Default+104, 4
       CopyMemory pi2_Default+204, dm_Default+108, 4
       CopyMemory pi2_Default+208, dm_Default+112, 4
       CopyMemory pi2_Default+212, dm_Default+116, 4
       CopyMemory pi2_Default+216, dm_Default+120, 4
       CopyMemory pi2_Default+220, dm_Default+124, 4
       CopyMemory pi2_Default+224, dm_Default+128, 4
       CopyMemory pi2_Default+228, dm_Default+132, 4
       CopyMemory pi2_Default+232, dm_Default+136, 4
      ELSE
       CopyMemory dm_Default+32, pi2_Default+128, 2
       CopyMemory dm_Default+34, pi2_Default+130, 2
       CopyMemory dm_Default+36, pi2_Default+132, 2
       CopyMemory dm_Default+38, pi2_Default+134, 2
       CopyMemory dm_Default+40, pi2_Default+136, 4
       CopyMemory dm_Default+44, pi2_Default+140, 2
       CopyMemory dm_Default+46, pi2_Default+142, 2
       CopyMemory dm_Default+48, pi2_Default+144, 2
       CopyMemory dm_Default+50, pi2_Default+146, 2
       CopyMemory dm_Default+52, pi2_Default+148, 2
       CopyMemory dm_Default+54, pi2_Default+150, 2
       CopyMemory dm_Default+56, pi2_Default+152, 2
       CopyMemory dm_Default+58, pi2_Default+154, 2
       CopyMemory dm_Default+60, pi2_Default+156, 2
       CopyMemory dm_Default+62, pi2_Default+158, 2
       CopyMemory dm_Default+64, pi2_Default+160, 2
       CopyMemory dm_Default+66, pi2_Default+162, 2
       CopyMemory dm_Default+68, pi2_Default+164, 2

       CopyMemory dm_Default+102, pi2_Default+198, 2
       CopyMemory dm_Default+104, pi2_Default+200, 4
       CopyMemory dm_Default+108, pi2_Default+204, 4
       CopyMemory dm_Default+112, pi2_Default+208, 4
       CopyMemory dm_Default+116, pi2_Default+212, 4
       CopyMemory dm_Default+120, pi2_Default+216, 4
       CopyMemory dm_Default+124, pi2_Default+220, 4
       CopyMemory dm_Default+128, pi2_Default+224, 4
       CopyMemory dm_Default+132, pi2_Default+228, 4
       CopyMemory dm_Default+136, pi2_Default+232, 4
      END IF
     END SUB

     SUB Get_Jobs(firstJob AS LONG, numJobs AS LONG)
      jobs_mem=0
      prt_error=1
      IF prt_opened=1 THEN
       rtn=EnumJobs(prt_Handle, firstJob, numJobs, 2, 0, 0, @needed, @rtnval)
       IF ((rtn=0) AND (GetLastError()=ERROR_INSUFFICIENT_BUFFER)) THEN
        jobs_Memory=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, needed)
        IF jobs_Memory<>0 THEN
         jobs_mem=1
         jobs_Default=GlobalLock(jobs_Memory)
         IF jobs_Default<>0 THEN
          jobs_Lock=jobs_Default
          rtn=EnumJobs(prt_Handle, firstJob, numJobs, 2, jobs_Default, needed, @needed, @rtnval)
          IF rtn=1 THEN
           prt_error=0

          END IF
         END IF
        END IF
       ELSE
        SHOWMESSAGE("No Jobs Printing")
       END IF
      END IF
     END SUB

     SUB Get_DCVersion
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_VERSION, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_VERSION, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
'rtn is the value.
      END IF
     END SUB

     SUB Get_DCDriver
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_DRIVER, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_DRIVER, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
'rtn is the value.
      END IF
     END SUB

     SUB Get_DCSize
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_SIZE, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_SIZE, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
'rtn is the value.
      END IF
     END SUB

     SUB Get_DCExtra
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_EXTRA, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_EXTRA, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
'rtn is the value.
      END IF
     END SUB

     SUB Get_DCFields
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_FIELDS, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_FIELDS, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
'rtn is the value.
      END IF
     END SUB

     SUB Get_DCOrientation
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_ORIENTATION, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_ORIENTATION, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
       IF rtn=0 THEN
'Landscape Orientation NOT Supported
       ELSEIF rtn=90 THEN
'Landscape Orientation: 90 degrees (Dot Matrix Printers)
       ELSEIF rtn=270 THEN
'Landscape Orientation: 270 degrees (Hewlett Packard PCL Printers)
       END IF
      END IF
     END SUB

     SUB Get_DCCopies
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_COPIES, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_COPIES, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
'rtn is the value.
      END IF
     END SUB

     SUB Get_DCDuplex
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_DUPLEX, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_DUPLEX, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
       IF rtn=0 THEN
'Duplex Printing NOT Supported
       ELSEIF rtn=1 THEN
'Duplex Printing Supported
       END IF
      END IF
     END SUB

     SUB Get_DCEmf
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_EMF_COMPLIANT, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_EMF_COMPLIANT, 0, 0)
      END IF
      IF rtn=-1 THEN
'EMF Not Supported
      ELSEIF rtn=1 THEN
       prt_error=0
'EMF Supported
      END IF
     END SUB

     SUB Get_DCDataType
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 1000)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_DATATYPE_PRODUCED, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_DATATYPE_PRODUCED, FInt, 0)
        END IF
        IF rtn=-1 THEN
'Only the RAW DataType Supported
        ELSE
         prt_error=0
         FOR count=0 TO rtn-1
' Copy the datatype names (FInt values) into the dtypes() array.
          dtypes(count)=FInt
          INC (FInt, 64)
         NEXT
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCBins
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 300)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_BINS, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_BINS, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         FOR count=0 TO rtn-1
          CopyMemory VARPTR(bins(count)), FInt, 2
          INC (FInt, 2)
         NEXT
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCBinAdjust
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_BINADJUST, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_BINADJUST, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
'rtn is the value.
      END IF
     END SUB

     SUB Get_DCBinNames
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 1000)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_BINNAMES, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_BINNAMES, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         FOR count=0 TO rtn-1
          CopyMemory VARPTR(bin_Name$(count)), FInt, 24
          INC (FInt, 24)
         NEXT
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCPapers
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 300)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_PAPERS, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_PAPERS, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         FOR count=0 TO rtn-1
          CopyMemory VARPTR(papers(count)), FInt, 2
          INC (FInt, 2)
         NEXT
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCPaperSize
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 300)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_PAPERSIZE, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_PAPERSIZE, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         FOR count=0 TO rtn-1
' Copy the X Y Points of the POINT structure into the papersizes array.
' POINT X and Y are measured in millimeters.
          CopyMemory VARPTR(papersizes((count*2))), FInt, 4
          CopyMemory VARPTR(papersizes((1+(count*2)))), FInt+4, 4
          INC (FInt, 8)
         NEXT
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCMinPaperSize
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 300)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_MINEXTENT, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_MINEXTENT, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         CopyMemory VARPTR(point(0)), FInt, 4
         CopyMemory VARPTR(point(1)), FInt+4, 4
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCMaxPaperSize
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 300)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_MAXEXTENT, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_MAXEXTENT, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         CopyMemory VARPTR(point(0)), FInt, 4
         CopyMemory VARPTR(point(1)), FInt+4, 4
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCPaperNames
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 2500)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_PAPERNAMES, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_PAPERNAMES, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         FOR count=0 TO rtn-1
          CopyMemory VARPTR(paper_Name$(count)), FInt, 64
          INC (FInt, 64)
         NEXT
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCResolutions
      prt_error=1
      FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 2500)
      IF FLong<>0 THEN
       FInt=GlobalLock(FLong)
       IF FInt<>0 THEN
        FLock=FInt
        IF dm_mem=1 THEN
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_ENUMRESOLUTIONS, FInt, dm_Default)
        ELSE
         rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_ENUMRESOLUTIONS, FInt, 0)
        END IF
        IF rtn<>-1 THEN
         prt_error=0
         FOR count=0 TO rtn-1
          CopyMemory VARPTR(resolutions((count*2))), FInt, 4
          CopyMemory VARPTR(resolutions((1+(count*2)))), FInt+4, 4
          INC (FInt, 8)
         NEXT
        END IF
        UnLock_DefaultMemory
       END IF
       Free_DefaultMemory
      END IF
     END SUB

     SUB Get_DCFontOptions
      prt_error=1
      IF dm_mem=1 THEN
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_TRUETYPE, 0, dm_Default)
      ELSE
       rtn=DeviceCapabilities(prt_Name$, prt_Port$, DC_TRUETYPE, 0, 0)
      END IF
      IF rtn<>-1 THEN
       prt_error=0
' You will need to check each bit of rtn for each bit you are interested
' in.
       IF (rtn AND DCTT_BITMAP)=DCTT_BITMAP THEN
'TrueType Fonts printed as Graphics (Dot Matrix Printer)
       ELSE

       END IF
      END IF
     END SUB

     SUB Get_Devmode
      dm_mem=0
      prt_error=1
      IF prt_opened=1 THEN
       stg$=""
       needed=DocumentProperties(0, prt_Handle, stg$, 0, 0, 0)
       IF needed>0 THEN
        dm_Memory=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, needed)
        IF dm_Memory<>0 THEN
         dm_mem=1
         dm_Default=GlobalLock(dm_Memory)
         IF dm_Default<>0 THEN
          dmLock=dm_Default
' copy the current devmode settings in dm_default memory.
          rtn=DocumentProperties(0, prt_Handle, stg$, dm_Default, 0, DM_COPY)
          IF rtn>-1 THEN
           prt_error=0

          END IF
         END IF
        END IF
       END IF
      END IF
     END SUB

     SUB Set_NewHBrush(Colour AS LONG, Style AS LONG)
      IF prt_DC<>0 THEN
       hbrush_set=0
       brush(0)=BS_HATCHED
       brush(1)=Colour
       brush(2)=Style
       hbrush=CreateBrushIndirect(@brush(0))
       IF hbrush<>0 THEN
        oldhbrush=SelectObject(prt_DC, hbrush)
        IF oldhbrush<>0 THEN
         hbrush_set=1
        ELSE
         SHOWMESSAGE("SelectObject failed")
        END IF
       ELSE
        SHOWMESSAGE("brush not created")
       END IF
      END IF
     END SUB

     SUB Restore_OldHBrush
      IF prt_DC<>0 THEN
       IF hbrush_set=1 THEN
        rtn=DeleteObject(hbrush)
        IF rtn=1 THEN
         hbrush_set=0
        ELSE
         SHOWMESSAGE("DeleteObject failed")
        END IF
       END IF
      END IF
     END SUB

     SUB Set_NewSBrush(colour AS LONG)
      IF prt_DC<>0 THEN
       sbrush_set=0
       sbrush=CreateSolidBrush(colour)
       IF sbrush<>0 THEN
        oldsbrush=SelectObject(prt_DC, sbrush)
        IF oldsbrush<>0 THEN
         sbrush_set=1
        ELSE
         SHOWMESSAGE("SelectObject failed")
        END IF
       ELSE
        SHOWMESSAGE("brush not created")
       END IF
      END IF
     END SUB

     SUB Restore_OldSBrush
      IF prt_DC<>0 THEN
       IF sbrush_set=1 THEN
        rtn=DeleteObject(sbrush)
        IF rtn=1 THEN
         sbrush_set=0
        ELSE
         SHOWMESSAGE("DeleteObject failed")
        END IF
       END IF
      END IF
     END SUB

     SUB Set_NewPBrush(bmw AS LONG, bmh AS LONG, bmp AS LONG, bmb AS LONG)
      IF prt_DC<>0 THEN
       pbrush_set=0
       bm_Handle=0
       bm_Handle=CreateBitmap(bmw, bmh, bmp, bmb, @bm_bitsArray(0))
       IF bm_Handle<>0 THEN
        pbrush=CreatePatternBrush(bm_Handle)
        IF pbrush<>0 THEN
         oldpbrush=SelectObject(prt_DC, pbrush)
         IF oldpbrush<>0 THEN
          pbrush_set=1
         ELSE
          SHOWMESSAGE("SelectObject failed")
         END IF
        ELSE
         SHOWMESSAGE("brush not created")
        END IF
       ELSE
        SHOWMESSAGE("CreateBitmap failed")
       END IF
      END IF
     END SUB

     SUB Restore_OldPBrush
      IF prt_DC<>0 THEN
       IF pbrush_set=1 THEN
        rtn=DeleteObject(pbrush)
        IF rtn=1 THEN
         pbrush_set=0
         rtn=DeleteObject(bm_Handle)
         IF rtn=1 THEN
          bm_Handle=0

         ELSE
          SHOWMESSAGE("DeleteObject bitmap failed")
         END IF
        ELSE
         SHOWMESSAGE("DeleteObject brush failed")
        END IF
       END IF
      END IF
     END SUB

     SUB Set_NewSFont(H AS LONG, W AS LONG, E AS LONG, O AS LONG, Weight AS LONG, I AS LONG, U AS LONG, S AS LONG, CS AS LONG, OP AS LONG, CP AS LONG, Q AS LONG, PAF AS LONG, Font AS LONG)
      IF prt_DC<>0 THEN
       sfont_set=0
       sfont=CreateFont(H, W, E, O, Weight, I, U, S, CS, OP, CP, Q, PAF, Font)
       IF sfont<>0 THEN
        oldsfont=SelectObject(prt_DC, sfont)
        IF oldsfont<>0 THEN
         sfont_set=1
        ELSE
         SHOWMESSAGE("SelectObject failed")
        END IF
       ELSE
        SHOWMESSAGE("font not created")
       END IF
      END IF
     END SUB

     SUB Restore_OldSFont
      IF prt_DC<>0 THEN
       IF sfont_set=1 THEN
        rtn=DeleteObject(sfont)
        IF rtn=1 THEN
         sfont_set=0
        ELSE
         SHOWMESSAGE("DeleteObject failed")
        END IF
       END IF
      END IF
     END SUB

     SUB Set_NewPen(Thickness AS BYTE, Colour AS LONG)
      IF prt_DC<>0 THEN
       pen_set=0
       pen=CreatePen(PS_SOLID, Thickness, Colour)
       IF pen<>0 THEN
        oldpen=SelectObject(prt_DC, pen)
        IF oldpen<>0 THEN
         pen_set=1
        ELSE
         SHOWMESSAGE("SelectObject failed")
        END IF
       ELSE
        SHOWMESSAGE("pen not created")
       END IF
      END IF
     END SUB

     SUB Restore_OldPen
      IF prt_DC<>0 THEN
       IF pen_set=1 THEN
        rtn=DeleteObject(pen)
        IF rtn=1 THEN
         pen_set=0
        ELSE
         SHOWMESSAGE("DeleteObject failed")
        END IF
       END IF
      END IF
     END SUB

     SUB Set_NewSObject(object AS LONG)
      IF prt_DC<>0 THEN
       sobject_set=0
       sobject=GetStockObject(object)
       IF sobject<>0 THEN
        oldsobject=SelectObject(prt_DC, sobject)
        IF oldsobject<>0 THEN
         sobject_set=1
        ELSE
         SHOWMESSAGE("SelectObject failed")
        END IF
       ELSE
        SHOWMESSAGE("stock_object not created")
       END IF
      END IF
     END SUB

     SUB Restore_OldSObject
      IF prt_DC<>0 THEN
       IF sobject_set=1 THEN
        rtn=DeleteObject(sobject)
        IF rtn=1 THEN
         sobject_set=0
        ELSE
         SHOWMESSAGE("DeleteObject failed")
        END IF
       END IF
      END IF
     END SUB

     SUB Print_DrawText(bufsize AS LONG, format AS LONG, left AS LONG, top AS LONG, right AS LONG, bottom AS LONG)
      IF prt_DC<>0 THEN
       dtRect(0)=left
       dtRect(1)=top
       dtRect(2)=right
       dtRect(3)=bottom
       rtn=DrawText(prt_DC, @text_buffer(0), bufsize, @dtRect(0), format)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("DrawText failed")
       END IF
      END IF
     END SUB

     SUB Print_Ellipse(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG)
      IF prt_DC<>0 THEN
       rtn=Ellipse(prt_DC, left, top, right, bottom)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("Ellipse failed")
       END IF
      END IF
     END SUB

     SUB Print_Rectangle(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG)
      IF prt_DC<>0 THEN
       rtn=Rectangle(prt_DC, left, top, right, bottom)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("Rectangle failed")
       END IF
      END IF
     END SUB

     SUB Print_RoundRect(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG, width AS LONG, height AS LONG)
      IF prt_DC<>0 THEN
       rtn=RoundRect(prt_DC, left, top, right, bottom, width, height)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("RoundRect failed")
       END IF
      END IF
     END SUB

     SUB Print_LineTo(x AS LONG, y AS LONG)
      IF prt_DC<>0 THEN
       rtn=LineTo(prt_DC, x, y)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("LineTo failed")
       END IF
      END IF
     END SUB

     SUB Print_MoveToEx(x AS LONG, y AS LONG)
      IF prt_DC<>0 THEN
       rtn=MoveToEx(prt_DC, x, y, 0)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("MoveToEx failed")
       END IF
      END IF
     END SUB

     SUB Get_BGColour
      IF prt_DC<>0 THEN
       bgColour=GetBkColor(prt_DC)
       IF bgColour<>CLR_INVALID THEN

       ELSE
        SHOWMESSAGE("GetBkColor failed")
       END IF
      END IF
     END SUB

     SUB Set_BGColour(colour AS LONG)
      IF prt_DC<>0 THEN
       oldBGColour=SetBkColor(prt_DC, colour)
       IF oldBGColour<>CLR_INVALID THEN

       ELSE
        SHOWMESSAGE("SetBkColor failed")
       END IF
      END IF
     END SUB

     SUB Get_BGMode
      IF prt_DC<>0 THEN
       bgMode=GetBkMode(prt_DC)
       IF bgMode<>0 THEN

       ELSE
        SHOWMESSAGE("GetBkMode failed")
       END IF
      END IF
     END SUB

     SUB Set_BGMode(mode AS LONG)
      IF prt_DC<>0 THEN
       oldBGMode=SetBkMode(prt_DC, mode)
       IF oldBGMode<>0 THEN

       ELSE
        SHOWMESSAGE("SetBkMode failed")
       END IF
      END IF
     END SUB

     SUB Print_PolyLine(numPoints AS LONG)
      IF prt_DC<>0 THEN
       rtn=PolyLine(prt_DC, @points(0), numPoints)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("PolyLine failed")
       END IF
      END IF
     END SUB

     SUB Print_PolyLineTo(numPoints AS LONG)
      IF prt_DC<>0 THEN
       rtn=PolyLineTo(prt_DC, @points(0), numPoints)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("PolyLineTo failed")
       END IF
      END IF
     END SUB

     SUB Print_FillRect(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG)
      IF prt_DC<>0 THEN
       rect(0)=left
       rect(1)=top
       rect(2)=right
       rect(3)=bottom
       rtn=FillRect(prt_DC, @rect(0), hbrush)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("FillRect failed")
       END IF
      END IF
     END SUB

     SUB Print_PolyBezierTo(numCurves AS LONG)
      IF prt_DC<>0 THEN
       rtn=PolyBezierTo(prt_DC, @curves(0), numCurves)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("PolyBezierTo failed")
       END IF
      END IF
     END SUB

     SUB Print_AngleArc(x AS LONG, y AS LONG, radius AS LONG, startAngle AS DOUBLE, sweepAngle AS DOUBLE)
      IF prt_DC<>0 THEN
       rtn=AngleArc(prt_DC, x, y, radius, startAngle, sweepAngle)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("AngleArc failed")
       END IF
      END IF
     END SUB

     SUB Print_Arc(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG, xpoint AS LONG, ypoint AS LONG, xarc AS LONG, yarc AS LONG)
      IF prt_DC<>0 THEN
       rtn=Arc(prt_DC, left, top, right, bottom, xpoint, ypoint, xarc, yarc)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("Arc failed")
       END IF
      END IF
     END SUB

     SUB Print_ArcTo(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG, xpoint AS LONG, ypoint AS LONG, xarc AS LONG, yarc AS LONG)
      IF prt_DC<>0 THEN
       rtn=ArcTo(prt_DC, left, top, right, bottom, xpoint, ypoint, xarc, yarc)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("ArcTo failed")
       END IF
      END IF
     END SUB

     SUB Print_Edge(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG, edge AS LONG, flags AS LONG)
      IF prt_DC<>0 THEN
       eRect(0)=left
       eRect(1)=top
       eRect(2)=right
       eRect(3)=bottom
       rtn=DrawEdge(prt_DC, @eRect(0), edge, flags)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("DrawEdge failed")
       END IF
      END IF
     END SUB

     SUB Print_FrameRectangle(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG, brush AS LONG)
      IF prt_DC<>0 THEN
       fRect(0)=left
       fRect(1)=top
       fRect(2)=right
       fRect(3)=bottom
       rtn=FrameRect(prt_DC, @fRect(0), brush)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("FrameRect failed")
       END IF
      END IF
     END SUB

     SUB Print_Chord(left AS LONG, top AS LONG, right AS LONG, bottom AS LONG, r1 AS LONG, r2 AS LONG, r3 AS LONG, r4 AS LONG)
      IF prt_DC<>0 THEN
       rtn=Chord(prt_DC, left, top, right, bottom, r1, r2, r3, r4)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("Chord failed")
       END IF
      END IF
     END SUB

     SUB Get_PixelRGB(x AS LONG, y AS LONG)
      IF prt_DC<>0 THEN
       pixelRGB=GetPixel(prt_DC, x, y)
       IF pixelRGB<>CLR_INVALID THEN

       ELSE
        SHOWMESSAGE("GetPixel failed")
       END IF
      END IF
     END SUB

     SUB Set_PixelRGB(x AS LONG, y AS LONG, colour AS LONG)
      IF prt_DC<>0 THEN
       pixelRGB=SetPixel(prt_DC, x, y, colour)
       IF pixelRGB<>-1 THEN

       ELSE
        SHOWMESSAGE("SetPixel failed")
       END IF
      END IF
     END SUB

     SUB Get_StretchMode
      IF prt_DC<>0 THEN
       currentSM=GetStretchBltMode(prt_DC)
       IF currentSM<>0 THEN

       ELSE
        SHOWMESSAGE("GetStretchBltMode failed")
       END IF
      END IF
     END SUB

     SUB Set_StretchMode(mode AS LONG)
      IF prt_DC<>0 THEN
       oldSM=SetStretchBltMode(prt_DC, mode)
       IF oldSM<>0 THEN

       ELSE
        SHOWMESSAGE("SetStretchBltMode failed")
       END IF
      END IF
     END SUB

     SUB Pattern_BitMap(x AS LONG, y AS LONG, w AS LONG, h AS LONG, copyMode AS LONG)
      IF prt_DC<>0 THEN
       rtn=PatBlt(prt_DC, x, y, w, h, copyMode)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("PatBlt failed")
       END IF
      END IF
     END SUB

     SUB Blit_BitMap(x AS LONG, y AS LONG, w AS LONG, h AS LONG, sourceDC AS LONG, xSource AS LONG, ySource AS LONG, copyMode AS LONG)
      IF prt_DC<>0 THEN
       rtn=BitBlt(prt_DC, x, y, w, h, sourceDC, xSource, ySource, copyMode)
       IF rtn<>0 THEN

       ELSE
' This will fail, as the code is, because I am using two different DC`s.
        SHOWMESSAGE("BitBlt failed")
       END IF
      END IF
     END SUB

     SUB Stretch_BitMap(x AS LONG, y AS LONG, w AS LONG, h AS LONG, sourceDC AS LONG, xSource AS LONG, ySource AS LONG, wSource AS LONG, hSource AS LONG, copyMode AS LONG)
      IF prt_DC<>0 THEN
       rtn=StretchBlt(prt_DC, x, y, w, h, bm_DC, xSource, ySource, wSource, hSource, copyMode)
       IF rtn<>0 THEN

       ELSE
        SHOWMESSAGE("StretchBlt failed")
       END IF
      END IF
     END SUB

     SUB Set_MapMode(mode AS LONG)
      IF prt_DC<>0 THEN
       oldMapMode=SetMapMode(prt_DC, mode)
       IF oldMapMode<>0 THEN

       ELSE
        SHOWMESSAGE("SetMapMode failed")
       END IF
      END IF
     END SUB

     SUB Get_MapMode
      IF prt_DC<>0 THEN
       mapMode=GetMapMode(prt_DC)
       IF mapMode<>0 THEN

       ELSE
        SHOWMESSAGE("GetMapMode failed")
       END IF
      END IF
     END SUB

     SUB Set_MapperFlags(flags AS LONG)
      IF prt_DC<>0 THEN
       oldMapFlags=SetMapperFlags(prt_DC, flags)
       IF oldMapFlags<>GDI_ERROR THEN

       ELSE
        SHOWMESSAGE("SetMapperFlags failed")
       END IF
      END IF
     END SUB

     SUB Set_GraphicsMode(mode AS LONG)
      IF prt_DC<>0 THEN
       oldGraphicsMode=SetGraphicsMode(prt_DC, mode)
       IF oldGraphicsMode<>GDI_ERROR THEN

       ELSE
        SHOWMESSAGE("SetGraphicsMode failed")
       END IF
      END IF
     END SUB

     SUB Set_TextColour(colour AS LONG)
      IF prt_DC<>0 THEN
       oldtextcolour=SetTextColor(prt_DC, colour)
       IF oldtextcolour<>CLR_INVALID THEN

       ELSE
        SHOWMESSAGE("SetTextColor failed")
       END IF
      END IF
     END SUB

     SUB Set_TextAlignment(flag AS LONG)
      IF prt_DC<>0 THEN
       oldtextalign=SetTextAlign(prt_DC, flag)
       IF oldtextalign<>GDI_ERROR THEN

       ELSE
        SHOWMESSAGE("SetTextAlign failed")
       END IF
      END IF
     END SUB

     SUB Set_TextSpacing(logicalunits AS LONG)
      IF prt_DC<>0 THEN
       oldtextspacing=SetTextCharacterExtra(prt_DC, logicalunits)
       IF oldtextspacing<>&H80000000 THEN

       ELSE
        SHOWMESSAGE("SetTextCharacterExtra failed")
       END IF
      END IF
     END SUB

     SUB Get_GraphicsMode
      IF prt_DC<>0 THEN
       graphicsMode=GetGraphicsMode(prt_DC)
       IF graphicsMode<>0 THEN

       ELSE
        SHOWMESSAGE("GetGraphicsMode failed")
       END IF
      END IF
     END SUB

     SUB Get_TextAlignment
      IF prt_DC<>0 THEN
       textalign=GetTextAlign(prt_DC)
       IF textalign<>CLR_INVALID THEN

       ELSE
        SHOWMESSAGE("GetTextAlign failed")
       END IF
      END IF
     END SUB

     SUB Get_TextColour
      IF prt_DC<>0 THEN
       textcolour=GetTextColor(prt_DC)
       IF textcolour<>CLR_INVALID THEN

       ELSE
        SHOWMESSAGE("GetTextColor failed")
       END IF
      END IF
     END SUB

     SUB Get_TextSpacing
      IF prt_DC<>0 THEN
       textspacing=GetTextCharacterExtra(prt_DC)
       IF textspacing<>&H8000000 THEN

       ELSE
        SHOWMESSAGE("GetTextCharacterExtra failed")
       END IF
      END IF
     END SUB

     SUB Print_TextOut(x AS LONG, y AS LONG, buffer AS LONG, bufsize AS LONG)
      prt_error=1
      IF prt_DC<>0 THEN
       rtn=TextOut(prt_DC, x, y, buffer, bufsize)
       IF rtn=1 THEN
        prt_error=0

       ELSE
        SHOWMESSAGE("Text not printed")
       END IF
      END IF
     END SUB

     SUB Set_Job

     END SUB

     SUB Get_Job
      prt_error=1
      job_mem=0
      IF prt_opened=1 THEN
       job_Memory=GlobalAlloc(GMEM_MOVEABLE OR GMEM_ZEROINIT, 3000)
       IF job_Memory<>0 THEN
        job_mem=1
        job_Default=GlobalLock(job_Memory)
        IF job_Default<>0 THEN
         job_Lock=job_Default
         rtn=GetJob(prt_Handle, jobID, 2, job_Default, 3000, @rtnval)
         IF rtn<>0 THEN
          prt_error=0

         END IF
        END IF
       END IF
      END IF
     END SUB

     SUB Modify_DevMode
      prt_error=1
      IF prt_opened=1 THEN
       rtn=DocumentProperties(0, prt_Handle, device_Name$, dm_Default, dm_Default, DM_MODIFY OR DM_COPY)
       IF rtn>-1 THEN
        IF rtn=IDOK THEN
         prt_error=0

        END IF
       END IF
      END IF
     END SUB

     SUB Set_Printer
      prt_error=1
      IF prt_opened=1 THEN
       FFour=0
       CopyMemory pi2_Default+48, VARPTR(FFour), 4
       SetPrinter(prt_Handle, 2, pi2_Default, 0)
       IF rtn<>0 THEN
        prt_error=0

       ELSE
        IF GetLastError()<>0 THEN
         SHOWMESSAGE("SetPrinter() Error: "+STR$(GetLastError()))
        ELSE
' You may end up here if you set portname of pi2->portname to a
' non-printer port name (i.e "COM1:"). Other pi2 fields may cause
' you to end up here.
        END IF
       END IF
      END IF
     END SUB

     SUB Abort_Printer
' This is one cool command! It really does STOP the printer`s jobs
' (including the current job).
      prt_error=1
      IF prt_opened=1 THEN
       AbortPrinter(prt_Handle)
       IF rtn<>0 THEN
        prt_error=0
        SHOWMESSAGE("Printer`s Spooler-File has been Deleted")
       ELSE
        SHOWMESSAGE(STR$(getlasterror())+" "+STR$(rtn))
       END IF
      END IF
     END SUB

     SUB Abort_Document
      prt_error=1
      IF prt_DC<>0 THEN
       AbortDoc(prt_DC)
       IF rtn>0 THEN
        prt_error=0
        SHOWMESSAGE("Document has been Aborted")
       ELSE
        SHOWMESSAGE(STR$(getlasterror())+" "+STR$(rtn))
       END IF
      END IF
     END SUB

     SUB Print_Text(useOutputFile AS BYTE)
      IF prt_opened=1 THEN

' Allocate memory for the DocInfo structure.
       FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 20)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt

' Initialize the DocInfo Structure.
         FFour=20
         CopyMemory FInt, VARPTR(FFour), 4
         FFour=VARPTR(emf_Title$)
         CopyMemory FInt+4, VARPTR(FFour), 4
         IF useOutputFile=0 THEN
          output_File$=""
         END IF
         FFour=VARPTR(output_File$)
         CopyMemory FInt+8, VARPTR(FFour), 4
         FFour=VARPTR(emf$)
         CopyMemory FInt+12, VARPTR(FFour), 4
         FFour=0
         CopyMemory FInt+16, VARPTR(FFour), 4

' Setup the Documentation Page.
         jobID=StartDoc(prt_DC, FInt)
         IF jobID>0 THEN

' Everything between StartPage and EndPage is one page. If you want
' to draw on another page (the next page) you must do another
' StartPage and EndPage after this one.

          rtn=StartPage(prt_DC)
          IF rtn>0 THEN

' Just play around with the font values below - I used most of the
' default values, but also used ITALIC, UNDERLINE etc to show they
' work. Note: CreateFontIndirect() isn`t that good for this code as
' it requires Byte format that doesn`t work properly (in this code only).
' Hence why I switched to CreateFont(), which shows that RapidQ can pass
' 14 arguments/parameters!!

' Note: The sizes reflect the fact that I am using a FINE setting on
' my printer (best quality).

' Font Height I would like is 36.
           hsize=-MulDiv(36, GetDeviceCaps(prt_DC, LOGPIXELSX), 72)
' Font Width I would like is 16.
           wsize=-MulDiv(16, GetDeviceCaps(prt_DC, LOGPIXELSY), 72)
' fontname.
           stg$="Futura Black BT"

' Put the Font into the DC, Print the Text and then Restore the Old Font.
           Set_NewSFont(hsize, wsize, 1, 1, FW_BOLD, ITALIC_ON, UNDERLINE_ON, STRIKEOUT_ON, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH OR FF_DONTCARE, VARPTR(stg$))
' TextOut() takes a buffer as an argument, not a string. Thus. You
' could pass the address of a buffer rather than the address of a String.
           stg$="The quick brown fox jumps over the lazy dog."
           Print_TextOut(0, 0, VARPTR(stg$), 44)
           Restore_OldSFont

           rtn=EndPage(prt_DC)
           IF rtn>0 THEN

           ELSE
            SHOWMESSAGE("EndPage failed")
           END IF
          ELSE
           SHOWMESSAGE("StartPage failed")
          END IF

' Put another StartPage and EndPage here if you want to print another
' page.

          rtn=EndDoc(prt_DC)
          IF rtn>0 THEN
' Finish Here
          ELSE
           SHOWMESSAGE("EndDoc failed")
          END IF
         ELSE
          SHOWMESSAGE("StartDoc failed")
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Print_Document(useOutputFile AS BYTE)
      IF prt_opened=1 THEN

' Allocate memory for the DocInfo structure.
       FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 20)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt

' Initialize the DocInfo Structure.
         FFour=20
         CopyMemory FInt, VARPTR(FFour), 4
         FFour=VARPTR(emf_Title$)
         CopyMemory FInt+4, VARPTR(FFour), 4
         IF useOutputFile=0 THEN
          output_File$=""
         END IF
         FFour=VARPTR(output_File$)
         CopyMemory FInt+8, VARPTR(FFour), 4
         FFour=VARPTR(emf$)
         CopyMemory FInt+12, VARPTR(FFour), 4
         FFour=0
         CopyMemory FInt+16, VARPTR(FFour), 4

' Setup the Documentation Page.
         jobID=StartDoc(prt_DC, FInt)
         IF jobID>0 THEN

' Everything between StartPage and EndPage is one page. If you want
' to draw on another page (the next page) you must do another
' StartPage and EndPage after this one.

          rtn=StartPage(prt_DC)
          IF rtn>0 THEN

' Print a Document. There are other ways to Allocate and Fill the buffer.
' You could fill/print one line at a time, change the buffer from LONG to
' STRING format, so that you can File.ReadStr() for example, etc.

           IF DIREXISTS (document_Dir$) <> 0 THEN
            IF FILEEXISTS (document_File$) <> 0 THEN
             IF File.OPEN (document_File$, fmOpenRead) <> 0 THEN
              size=file.size
              DEC (size, 2) ' The proper file-size
              FOR count=0 TO size : text_buffer(count)=file.readnum(1) : NEXT
              File.CLOSE
              Print_DrawText(size, DT_LEFT OR DT_WORDBREAK OR DT_NOCLIP, 0, 0, 3200, 3200)
             ELSE
              File.CLOSE
              SHOWMESSAGE(document_File$+"\n\nThe above file was Not Loaded")
             END IF
            ELSE
             SHOWMESSAGE(document_File$+"\n\nThe above file was Not Found")
            END IF
           ELSE
            SHOWMESSAGE(document_Dir$+"\n\nThis Directory/Folder was Not Found")
           END IF

           rtn=EndPage(prt_DC)
           IF rtn>0 THEN

           ELSE
            SHOWMESSAGE("EndPage failed")
           END IF
          ELSE
           SHOWMESSAGE("StartPage failed")
          END IF

' Put another StartPage and EndPage here if you want to print another
' page.

          rtn=EndDoc(prt_DC)
          IF rtn>0 THEN
' Finish Here
          ELSE
           SHOWMESSAGE("EndDoc failed")
          END IF
         ELSE
          SHOWMESSAGE("StartDoc failed")
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Print_RAWBuffer(useOutputFile AS BYTE)
      IF prt_opened=1 THEN

' Allocate memory for the DocInfo1 structure.
       FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 12)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt

' Initialize the DocInfo1 Structure.
         FFour=VARPTR(raw_Title$)
         CopyMemory FInt, VARPTR(FFour), 4
         IF useOutputFile=0 THEN
          output_File$=""
         END IF
         FFour=VARPTR(output_File$)
         CopyMemory FInt+4, VARPTR(FFour), 4
         FFour=VARPTR(raw$)
         CopyMemory FInt+8, VARPTR(FFour), 4

         jobID=StartDocPrinter(prt_Handle, 1, FInt)
         IF jobID<>0 THEN
          rtn=StartPagePrinter(prt_Handle)
          IF rtn<>0 THEN

' PAUSE this Job (not the Printer).
           rtn=SetJob(prt_Handle, jobID, 0, 0, JOB_CONTROL_PAUSE)
           IF rtn<>0 THEN

' Get this Job`s info.
            Get_Job

' Change this job`s Priority. The job_info_2 structure is the same
' as jobs_Default (see Show_Jobs).
            FFour=67
            CopyMemory job_Default+56, VARPTR(FFour), 4

' RESUME this Job.
            rtn=SetJob(prt_Handle, jobID, 2, job_Default, JOB_CONTROL_RESUME)
            IF rtn<>0 THEN

' Print some RAW data.
             rtn=WritePrinter(prt_Handle, @raw_buffer(0), 1000, @rtnval)
             IF rtn<>0 THEN

' FINISH here.

             END IF
            END IF

' Free this Job`s memory.
            Free_jobMemory

           END IF

           rtn=EndPagePrinter(prt_Handle)
           IF rtn<>0 THEN

           ELSE
            SHOWMESSAGE("EndPagePrinter failed")
           END IF
          ELSE
           SHOWMESSAGE("StartPagePrinter failed")
          END IF
          rtn=EndDocPrinter(prt_Handle)
          IF rtn<>0 THEN
' Finish here
          ELSE
           SHOWMESSAGE("EndDocPrinter failed")
          END IF
         ELSE
          SHOWMESSAGE("StartDocPrinter failed")
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Print_Graphics(useOutputFile AS BYTE)
      IF prt_opened=1 THEN

' Allocate memory for the DocInfo structure.
       FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 20)
       IF FLong<>0 THEN
        FInt=GlobalLock(FLong)
        IF FInt<>0 THEN
         FLock=FInt

' Initialize the DocInfo Structure.
         FFour=20
         CopyMemory FInt, VARPTR(FFour), 4
         FFour=VARPTR(emf_Title$)
         CopyMemory FInt+4, VARPTR(FFour), 4
         IF useOutputFile=0 THEN
          output_File$=""
         END IF
         FFour=VARPTR(output_File$)
         CopyMemory FInt+8, VARPTR(FFour), 4
         FFour=VARPTR(emf$)
         CopyMemory FInt+12, VARPTR(FFour), 4
         FFour=0
         CopyMemory FInt+16, VARPTR(FFour), 4

' Setup the Documentation Page.
         jobID=StartDoc(prt_DC, FInt)
         IF jobID>0 THEN

' Everything between StartPage and EndPage is one page. If you want
' to draw on another page (the next page) you must do another
' StartPage and EndPage after this one.

          rtn=StartPage(prt_DC)
          IF rtn>0 THEN

' -------------- Information which you can Get and/or Set ------------

' These calls are to do with the DC. Things such as Colour, Modes,
' Text, etc. Similar calls are made within this Print_Graphics sub,
' that create Brushes, Pens, BitMap, etc.

'Get_GraphicsMode
'Get_MapMode
'Get_TextColour
'Get_TextAlignment
'Get_TextSpacing
'Get_BGColour
'Get_BGMode

'Set_GraphicsMode(GM_ADVANCED)
'Set_MapMode(MM_TEXT)
'Set_MapperFlags(&H00000000)
'Set_TextColour(&H00000000)
'Set_TextAlignment(TA_LEFT OR TA_TOP OR TA_UPDATECP)
'Set_BGColour(&H00000001)
'Set_BGMode(TRANSPARENT)

'Set_TextSpacing(??) <--- logicalunits.

' ------------------------------ Arc ---------------------------------

'Print_Arc(0, 50, 200, 150, 200, 100, 0, 100)
'Print_ArcTo(0, 50, 200, 150, 200, 100, 0, 100) ' windows NT only.
'Print_AngleArc(100, 150, 50, 0, 180) ' windows NT only.

' -------------------------- Chord Printing ---------------------------

'Print_Chord(0, 0, 100, 100, 50, 50, 50, 50)

' -------------------------- Draw Edge -------------------------------

' DrawEdge() is windows 95 and NT only.
'Print_Edge(0, 0, 100, 100, EDGE_RAISED, BF_DIAGONAL_ENDBOTTOMRIGHT OR BF_RECT)

' ---------------------------- Frame Rectangle -----------------------

' This call set the DC`s Brush to Solid, Prints a FrameRectangle and
' then restores the Old Brush. &H00000000 = Colour.

'Set_NewSBrush(&H00000000)
'Print_FrameRectangle(0, 0, 100, 100, sbrush)
'Restore_OldSBrush

' --------------------------- PolyBezierTo ----------------------------

' This calls gets a Stock Object (here a Pen), Prints a PolyBezier and
' then restores the Old Stock Object.

'Print_MoveToEx(0, 0)
'Set_NewSObject(BLACK_PEN)
           curves(0)=125
           curves(1)=75
           curves(2)=150
           curves(3)=125
           curves(4)=175
           curves(5)=100
           curves(6)=225
           curves(7)=50
           curves(8)=300
           curves(9)=150
           curves(10)=250
           curves(11)=200
'Print_PolyBezierTo(6)
'Restore_OldSObject

' ---------------------------- FillRect -------------------------------

' This calls sets the Brush to Hatched (Diagonal), Fills a Rectangle
' with the Hatched Brush (Pattern) and then restores the Old Brush.

'Set_NewHBrush(&H00000000, HS_FDIAGONAL)
'Print_FillRect(0, 0, 120, 120)
'Restore_OldHBrush

' This calls sets the Brush to Hatched (Diagonal), Fills a Rectangle
' with the Hatched Brush (Pattern) and then restores the Old Brush.

' There are two things to note here. 1 Always restore your old brushes,
' etc. And 2. The pre-defined (Hatched) Pattern. Both are Diagonal, but
' in two different directions.

'Set_NewHBrush(&H00000000, HS_BDIAGONAL)
'Print_FillRect(100, 100, 220, 220)
'Restore_OldHBrush

' ------------------------------ Lines --------------------------------

' This call sets the (Solid) Pen to a thickness of 5, draws Lines and
' then Restores the Old Pen.

'Set_NewPen(5, &H00000000)

'Print_LineTo(100, 0)   ' draw from current graphic cursor position (0,0)
                       ' to 100 across, 0 down.
'Print_LineTo(100, 100) ' draw from (above position) 100,0 to 100 across
                       ' 100 down. -----¬
                       '                 |
                       '                 |

' draw a pair of steps maybe?!!! Each point represents a x and y co-ord.
           points(0)=0     ' point 1
           points(1)=0
           points(2)=0     ' point 2
           points(3)=100
           points(4)=100   ' point 3
           points(5)=100
           points(6)=100   ' point 4
           points(7)=200
           points(8)=200   ' point 5
           points(9)=200
'Print_PolyLine(5)  ' Doesn`t update the current graphic cursor position.
'Print_PolyLineTo(5) ' but this does!!!

'Restore_OldPen

' |
' |
' |------¬
'         |
'         |
'         --------

' Note. By doing lineto() and polyline() etc together the cursor position
' may cut across your page, to get back to its original place etc. This
' is normal (Anyone who owned a BBC Micro with Turtle will know this). It
' is not this program. The trick, in those days, was to set the Pen
' Colour to white (the colour of your Paper). Reset the graphic cursor
' and then set the Pen Colour back to black or whatever. Laziness has
' forbid me to try this! (my Epson RX-80 might have an heart attack
' if I push it too much). The Epson RX-80 is an old B/W 9 Pin Dot Matrix
' for those who don`t know - Alright for printing Bills and Code though!

' -------------------- Ellipse, Rectangle and RoundRect ---------------

' This call sets the (Solid) Pen to a thickness of 5, draws an Ellipse,
' draws a Round Rectangle within a normal Rectangle and then Restores
' the Old Pen.

' This call also shows Abort_Document. If you use this (anywhere) then
' EndDoc and EndPage naturally give a failed message/return. This is
' normal.

'Set_NewPen(5, &H00000000)

'Print_Ellipse(20, 0, 100, 100)

' STOP this document from Printing. Note. By the time the Ellipse
' command has begun the Abort_Document command has STOPPED the document.
' Nice and Fast!! Remember. The printer is a seperate task so the
' Abort_Document command will execute next (i.e Abort_Document will not
' and does not wait for Print_Ellipse to finish).
'
'Abort_Document

'Print_Rectangle(440, 200, 100, 100)
'Print_RoundRect(360, 200, 100, 100, 100, 100)

'Restore_OldPen

' ----------------------- BitMap Brush (Pattern------------------------

' This call draws two BitMap Patterned Rectangles. It shows how easy
' it is to create a BitMap.

' Set the bitmap`s pattern.
           bm_bitsArray(0)=&HFFFFFFFF
           bm_bitsArray(1)=&HFFFFFFFF
           bm_bitsArray(2)=&H00000000
           bm_bitsArray(3)=&H00000000
           bm_bitsArray(4)=&H00000000
           bm_bitsArray(5)=&H00000000
           bm_bitsArray(6)=&HFFFFFFFF
           bm_bitsArray(7)=&HFFFFFFFF
'Set_NewPBrush(8, 8, 1, 1)       ' put the bitmap pattern into the DC.
'Print_Rectangle(0, 0, 100, 100) ' Draw a Rectangle with bitmap pattern.

'Print_FrameRectangle(0, 0, 100, 100, pbrush) ' dont appear to work?
'Restore_OldPBrush

' Change the bitmap`s pattern.
           bm_bitsArray(0)=&HF000000F
           bm_bitsArray(1)=&HF000000F
           bm_bitsArray(2)=&HF000000F
           bm_bitsArray(3)=&HF000000F
           bm_bitsArray(4)=&HF000000F
           bm_bitsArray(5)=&HF000000F
           bm_bitsArray(6)=&HF000000F
           bm_bitsArray(7)=&HF000000F
'Set_NewPBrush(8, 8, 1, 1)         ' put the bitmap pattern into the DC.
'Print_Rectangle(0, 120, 100, 220) ' Draw a Rectangle with bitmap pattern.
'Restore_OldPBrush

' ---------------------------- BitMap ----------------------------------

' This call prints part of the DeskTop`s Bitmap to the Printer. It
' shows BitBlt(), PatBlt() and StretchBlt() in action.

           rtn=GetDeviceCaps(prt_DC, RASTERCAPS)
           IF rtn<>0 THEN
' Here you should check wether or not your Printer supports bitmap etc,
' but I haven`t because I know my Epson RX-80 does (I checked the rtn
' value anyway just to make sure!). Not unless you have a really old
' printer (text only for example) would you need to check the rtn value.

            bm_Window=GetDesktopWindow()
            bm_DC=GetDC(bm_Window) 'bm_Window)
            IF bm_DC<>0 THEN

'Get_StretchMode
             Set_StretchMode(BLACKONWHITE)

' Do a straight copy.
'Blit_BitMap(0, 0, 300, 200, bm_DC, 0, 0, SRCCOPY)

' Stretch the bitmap.
'Stretch_BitMap(0, 0, 400, 400, bm_DC, 0, 0, 200, 200, SRCCOPY)

' Shrink the bitmap.
'Stretch_BitMap(0, 0, 400, 300, bm_DC, 0, 0, 800, 600, SRCCOPY)

' Change the bitmap`s pattern.
             bm_bitsArray(0)=&HF000000F
             bm_bitsArray(1)=&HFFFFFFFF
             bm_bitsArray(2)=&HF000000F
             bm_bitsArray(3)=&HF000000F
             bm_bitsArray(4)=&HFFFFFFFF
             bm_bitsArray(5)=&HF000000F
             bm_bitsArray(6)=&HF000000F
             bm_bitsArray(7)=&HFFFFFFFF
'Set_NewPBrush(8, 8, 1, 1)         ' put the bitmap pattern into the DC.
'Pattern_BitMap(0, 0, 100, 100, PATCOPY)
'Restore_OldPBrush

             rtn=ReleaseDC(bm_Window, bm_DC)
             IF rtn<>0 THEN

             ELSE
              SHOWMESSAGE("ReleaseDC failed")
             END IF
            ELSE
             SHOWMESSAGE("GetDC failed")
            END IF
           ELSE
            SHOWMESSAGE("GetDeviceCaps failed")
           END IF

           rtn=EndPage(prt_DC)
           IF rtn>0 THEN

           ELSE
            SHOWMESSAGE("EndPage failed")
           END IF
          ELSE
           SHOWMESSAGE("StartPage failed")
          END IF

' Put another StartPage and EndPage here if you want to print another
' page.

          rtn=EndDoc(prt_DC)
          IF rtn>0 THEN
' Finish Here
          ELSE
           SHOWMESSAGE("EndDoc failed")
          END IF
         ELSE
          SHOWMESSAGE("StartDoc failed")
         END IF
         UnLock_DefaultMemory
        END IF
        Free_DefaultMemory
       END IF
      END IF
     END SUB

     SUB Close_Printer
      IF prt_opened=1 THEN
       rtn=ClosePrinter(prt_Handle)
       IF rtn=1 THEN
        prt_opened=0
        prt_error=0
       ELSE
        prt_error=1
        SHOWMESSAGE("Printer - Not Closed")
       END IF
      END IF
     END SUB

     SUB Delete_DC
      IF prt_DC<>0 THEN
       rtn=DeleteDC(prt_DC)
       IF rtn=1 THEN
        prt_DC=0
       ELSE
        SHOWMESSAGE("DC - Not Deleted")
       END IF
      END IF
     END SUB

' Just remove the apostrophe for the function you want to use below.

' --------------------- Printer Setup Calls ---------------------------

'Enum_Ports("", 2)
'Enum_Drivers("", 2)
'Enum_Printers(PRINTER_ENUM_LOCAL, "", 5, ENUMERATE_PRINTERS, "", "")

' Change the Name field to your Printer`s Name.
' If your printer does not set the DEFAULT attribute upon calling
' Enum_Printers (perhaps because you have a Fax Printer attached)
' the name in the name field will act as a default printer name.
' This is so your computer is less likely to report an error and/or
' Crash, etc.
'
'Enum_Printers(PRINTER_ENUM_LOCAL, "", 5, ENUMERATE_DEFAULT_PRINTER, "Epson RX80", "LPT1:")

' Windows 2000 Pro:  I have used RapidQ`s own Printer.Printers(Number)
'                    array for the Printer Name, below. You should
'                    really search the array before calling
'                    Open_Printer() to get the correct array (printer)
'                    number.
'
     prt_Name$=Printer.Printers(1) ' Fax is 0.

' So to clarify the above said. Win98/SE users need to Enum_Printers()
' from above - that`s it. Win2000Pro users do NOT use Enum_Printers().
' They use prt_Name$=Printer.Printers(printer_number) instead.
'
' The differences are to do with the way the pointers work in RapidQ.
' Also because in win98SE Printer.Printers() equals "Epson RX80 on LPT1:"
' (with my Printer for example) but in win2000pro printer.Printers()
' equals "Epson RX80". So it`s up to you which way you get your printer`s
' name in win98SE - trim Printer.Printers() or use Enum_Printers().
'
     Open_Printer()
     Create_DC()

'Get_DevMode
'Show_DevMode

' Get_Driver is the same as Enum_Drivers except it enumerates the
' currently opened printer (printer-driver), specified by prt_Handle.
'
'Get_Driver("", 2)

' Although you do not need to call this for general Printing, it is a
' good idea to call it - just in case other functions need its data.
' It gets the Printer_Info_2 structure.
'Get_PI2
'Show_PI2

'Get_Jobs(0, 1) ' If you need to use Get_Jobs, call Get_PI2 first.
'Show_Jobs
'Free_jobsMemory

'Copy_DevMode(DDM_COPYTO_PI2DM) ' Copy default DevMode to PI2->DevMode
'Set_Printer                    ' Globally tell windows of the copy (new
                               ' DevMode settings).
'Show_PI2                      ' Show the change worked!


' ----------------- Print Graphics (BitMap, Shapes, etc) ---------------

' This sub has many examples for you to see.
'
'Print_Graphics(DATA_TO_PRINTER)

' --------------- Print TEXT (with optional specified FONT) ------------

' see the Print_Text sub for more information.
'
'Print_Text(DATA_TO_PRINTER)

' -------------------------- Print a Document -------------------------

' This needs the file: C:\My Documents\Test.txt
'
'Print_Document(DATA_TO_PRINTER)

' ------------------------- Print a RAW Buffer -----------------------

' This sub also shows how to getjob() and setjob().
'
'Print_RawBuffer(DATA_TO_PRINTER)

' ------------------------- Device Capabilities ----------------------

' These calls get most of the, important, device capabilities.
' You would typically use these to check/find out what your or
' another machine`s printer is capable of. There are plenty of
' useful things here. BINS, DUPLEX, COPIES etc. Read win32api manual
' or something for more specific information.

'Get_DCVersion
'Get_DCDriver
'Get_DCSize
'Get_DCExtra
'Get_DCFields
'Get_DCOrientation
'Get_DCCopies
'Get_DCDuplex
'Get_DCEmf
'Get_DCDataType
'Get_DCBins
'Get_DCBinAdjust
'Get_DCBinNames
'Get_DCPapers
'Get_DCPaperSize
'Get_DCMinPaperSize
'Get_DCMaxPaperSize
'Get_DCPaperNames
'Get_DCResolutions
'Get_DCFontOPtions

' ---------------------------- Set Printer ----------------------------

' A demo to show SetPrinter() and PRINTER_INFO_2 working together.
' ConfigurePort is usually pointing to a normal string (i.e prt_Port$)
' but here I have changed it to look at PRINTER_INFO_2->PORTNAME (which
' is a pointer to a string).
'
' Note: Do not just change the PRINTER_INFO_2->PORTNAME element and
' then call ConfigurePort(). This will only allow you to configure
' the port but not affect/change the printer`s port. To affect/change
' the printer`s port aswell you should call SetPrinter().

' TECHNICAL NOTES (Below):
'
' pi2_Default+12 is storing a LONG value. That LONG value is the address
' of (pointer to) the PortName string. It is not the string itself.
' Therefore. CopyMemory() is copying the LONG value into the variable
' FAdr. You need CopyMemory() as FAdr=pi2_Default+12 won`t work, simply
' because that would be copying the value of pi2_Default+12 itself into
' the variable FAdr and not the Pointer pi2_Default+12 is storing.
'
' The second CopyMemory() copies the string "COM1:"+0 into the Pointer
' (Address) which FAdr is storing (pointing to). As FAdr is pointing
' to the place (Address) where pi2->PortName lives (pi2_Default+12)
' I am poking pi2_PortName with a new string ("COM1:"+0 - Instead of
' "LPT1:"+0).
'
' As I have now changed a field of pi2 (pi2->PortName) I SetPrinter()
' those changes - Globally telling the Printer Driver that the printer
' port is now COM1: and no longer LPT1:
'
' NOTE: SetPrinter() returns an error of 0 (NO_ERROR) for COM1: as it
'       knows COM1: is not a Printer Port!!

'CopyMemory VarPtr(FAdr), pi2_Default+12, 4
'stg$="COM1:"+CHR$(0)
'CopyMemory FAdr, VarPtr(stg$), 6
'Set_Printer
'Configure_Port(0, FAdr)

' -------- Set Default DevMode and/or PI2 and/or PI2-->DevMode --------

' Note: Not all printers support everything below (Consult your printer
' manual).

' DEVMODE.
'---------

'Set_Orientation(DMORIENT_LANDSCAPE, SET_DDM)
'Set_PaperSize(DMPAPER_USER, SET_DDM)
'Set_PaperWidth(500, SET_DDM)         ' DMPAPER_USER must be used if you
'Set_PaperLength(300, SET_DDM)        ' want to use paper width/length.
'Set_Scale(50, SET_DDM)
'Set_Copies(3, SET_DDM)
'Set_PaperFeed(DMBIN_ENVELOPE, SET_DDM)
'Set_PrintQuality(DMRES_HIGH, SET_DDM)  ' A positive number = X DPI.
'Set_ColourMode(DMCOLOR_COLOR, SET_DDM)
'Set_Duplex(DMDUP_SIMPLEX, SET_DDM)
'Set_PrintQuality(240, SET_DDM)          ' A positive number = X DPI.
'Set_YResolution(144, SET_DDM)           ' The Y DPI (Dots Per Inch).
'Set_TTOption(DMTT_BITMAP, SET_DDM)
'Set_Collate(DMCOLLATE_FALSE, SET_DDM)
'Set_PixelsPerLogicalInch(0, SET_DDM)
'Set_ICMMethod(DMICMMETHOD_NONE, SET_DDM)
'Set_ICMIntent(DMICM_SATURATE, SET_DDM)
'Set_MediaType(DMMEDIA_STANDARD, SET_DDM)
'Set_DitherType(DMDITHER_COARSE, SET_DDM)

' PI2
' ---

' Only use these if you know what you are doing.
'Set_ServerName("")
'Set_PrinterName("Epson RX-80")
'Set_ShareName("")
'Set_PortName("LPT1:")
'Set_DriverName("Epson RX-80")
'Set_Location("")
'Set_SeperatorFile("")
'Set_PrintProcessor("WinPrint")
'Set_DataType("RAW")
'Set_Parameters("")

' When you are ready to set any one/all of the above commands simply
' call Set_Printer.
'Copy_DevMode(DDM_COPYTO_PI2DM) ' Copy Default DevMode to PI2-->DevMode.
'Set_Printer                    ' Set all the PI2 fields, including
                               ' PI2-->DevMode fields.

' --------------------- Printer Setup Requesters ---------------------

'PageSetupDialog
'Print_Dialog
'Properties_Window
'Advanced_Document_Properties
'Document_Properties
'Configure_Port(0, VarPtr(prt_Port$))

' ---------------------------- Cleanup Calls --------------------------

' These cleanup calls take care of their own error checking, etc.

     Delete_DC
     Close_Printer
'Free_pdMemory
'Free_dmMemory
'Free_pi2Memory

' ------------------------------- THE END :( --------------------------
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sun 2024-4-14  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-11-26 23:17:14