$OPTIMIZE ON
$APPTYPE GUI
$TYPECHECK ON
$ESCAPECHARS ON
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
CONST DCTT_DOWNLOAD = 2
CONST DCTT_SUBDEV = 3
CONST DI_APPBANDING = &H1
CONST DI_ROPS_READ_DESTINATION = &H2
CONST PHYSICALWIDTH = 110
CONST PHYSICALHEIGHT = 111
CONST PHYSICALOFFSETX = 112
CONST PHYSICALOFFSETY = 113
CONST SCALINGFACTORX = 114
CONST SCALINGFACTORY = 115
CONST CURVECAPS = 28
CONST LINECAPS = 30
CONST POLYGONALCAPS = 32
CONST TEXTCAPS = 34
CONST CLIPCAPS = 36
CONST RASTERCAPS = 38
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
CONST LOGPIXELSY = 90
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
CONST PSD_MARGINS = &H2
CONST PSD_INTHOUSANDTHSOFINCHES = &H4
CONST PSD_INHUNDREDTHSOFMILLIMETERS = &H8
CONST PSD_DISABLEMARGINS = &H10
CONST PSD_DISABLEPRINTER = &H20
CONST PSD_NOWARNING = &H80
CONST PSD_DISABLEORIENTATION = &H100
CONST PSD_RETURNDEFAULT = &H400
CONST PSD_DISABLEPAPER = &H200
CONST PSD_SHOWHELP = &H800
CONST PSD_ENABLEPAGESETUPHOOK = &H2000
CONST PSD_ENABLEPAGESETUPTEMPLATE = &H8000
CONST PSD_ENABLEPAGESETUPTEMPLATEHANDLE = &H20000
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
CONST RC_BANDING = 2
CONST RC_SCALING = 4
CONST RC_BITMAP64 = 8
CONST RC_GDI20_OUTPUT = &H10
CONST RC_GDI20_STATE = &H20
CONST RC_SAVEBITMAP = &H40
CONST RC_DI_BITMAP = &H80
CONST RC_PALETTE = &H100
CONST RC_DIBTODEV = &H200
CONST RC_BIGFONT = &H400
CONST RC_STRETCHBLT = &H800
CONST RC_FLOODFILL = &H1000
CONST RC_STRETCHDIB = &H2000
CONST RC_OP_DX_OUTPUT = &H4000
CONST RC_DEVBITS = &H8000
CONST SRCCOPY = &HCC0020
CONST SRCPAINT = &HEE0086
CONST SRCAND = &H8800C6
CONST SRCINVERT = &H660046
CONST SRCERASE = &H440328
CONST NOTSRCCOPY = &H330008
CONST NOTSRCERASE = &H1100A6
CONST MERGECOPY = &HC000CA
CONST MERGEPAINT = &HBB0226
CONST PATCOPY = &HF00021
CONST PATPAINT = &HFB0A09
CONST PATINVERT = &H5A0049
CONST DSTINVERT = &H550009
CONST BLACKNESS = &H42
CONST WHITENESS = &HFF0062
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
CONST BF_SOFT = &H1000
CONST BF_ADJUST = &H2000
CONST BF_FLAT = &H4000
CONST BF_MONO = &H8000
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
CONST DMDITHER_COARSE = 2
CONST DMDITHER_FINE = 3
CONST DMDITHER_LINEART = 4
CONST DMDITHER_GRAYSCALE = 5
CONST DMDITHER_USER = 256
CONST DMCOLOR_MONOCHROME = 1
CONST DMCOLOR_COLOR = 2
CONST DMDUP_SIMPLEX = 1
CONST DMDUP_VERTICAL = 2
CONST DMDUP_HORIZONTAL = 3
CONST DMPAPER_LETTER = 1
CONST DMPAPER_LETTERSMALL = 2
CONST DMPAPER_TABLOID = 3
CONST DMPAPER_LEDGER = 4
CONST DMPAPER_LEGAL = 5
CONST DMPAPER_STATEMENT = 6
CONST DMPAPER_EXECUTIVE = 7
CONST DMPAPER_A3 = 8
CONST DMPAPER_A4 = 9
CONST DMPAPER_A4SMALL = 10
CONST DMPAPER_A5 = 11
CONST DMPAPER_B4 = 12
CONST DMPAPER_B5 = 13
CONST DMPAPER_FOLIO = 14
CONST DMPAPER_QUARTO = 15
CONST DMPAPER_10X14 = 16
CONST DMPAPER_11X17 = 17
CONST DMPAPER_NOTE = 18
CONST DMPAPER_ENV_9 = 19
CONST DMPAPER_ENV_10 = 20
CONST DMPAPER_ENV_11 = 21
CONST DMPAPER_ENV_12 = 22
CONST DMPAPER_ENV_14 = 23
CONST DMPAPER_CSHEET = 24
CONST DMPAPER_DSHEET = 25
CONST DMPAPER_ESHEET = 26
CONST DMPAPER_ENV_DL = 27
CONST DMPAPER_ENV_C5 = 28
CONST DMPAPER_ENV_C3 = 29
CONST DMPAPER_ENV_C4 = 30
CONST DMPAPER_ENV_C6 = 31
CONST DMPAPER_ENV_C65 = 32
CONST DMPAPER_ENV_B4 = 33
CONST DMPAPER_ENV_B5 = 34
CONST DMPAPER_ENV_B6 = 35
CONST DMPAPER_ENV_ITALY = 36
CONST DMPAPER_ENV_MONARCH = 37
CONST DMPAPER_ENV_PERSONAL = 38
CONST DMPAPER_FANFOLD_US = 39
CONST DMPAPER_FANFOLD_STD_GERMAN = 40
CONST DMPAPER_FANFOLD_LGL_GERMAN = 41
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
CONST DMTT_DOWNLOAD = 2
CONST DMTT_SUBDEV = 3
CONST DMTT_DOWNLOAD_OUTLINE = 4
CONST DMCOLLATE_FALSE = 0
CONST DMCOLLATE_TRUE = 1
CONST DMICMMETHOD_NONE = 1
CONST DMICMMETHOD_SYSTEM = 2
CONST DMICMMETHOD_DRIVER = 3
CONST DMICMMETHOD_DEVICE = 4
CONST DMICMMETHOD_USER = 256
CONST DMICM_SATURATE = 1
CONST DMICM_CONTRAST = 2
CONST DMICM_COLORMETRIC = 3
CONST DMICM_USER = 256
CONST DMMEDIA_STANDARD = 1
CONST DMMEDIA_TRANSPARENCY = 2
CONST DMMEDIA_GLOSSY = 3
CONST DMMEDIA_SPECIALPAPER=269
CONST DMMEDIA_BOND=268
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
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
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
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
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
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
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))
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))
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))
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))
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))
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))
CopyMemory VARPTR(FAdr), jobs_Default+44, 4
SHOWMESSAGE("GJ - Status String: "+VARPTR$(FAdr))
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))
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))
END IF
END SUB
SUB Free_dmMemory
IF dm_mem=1 THEN
rtn=GlobalUnlock(dmLock)
IF ((rtn=0) AND (GetLastError()=0)) THEN
ELSE
END IF
rtn=GlobalFree(dm_Memory)
IF rtn=0 THEN
dm_mem=0
ELSE
END IF
END IF
END SUB
SUB Free_pi2Memory
IF pi2_mem=1 THEN
rtn=GlobalUnlock(pi2Lock)
IF ((rtn=0) AND (GetLastError()=0)) THEN
ELSE
END IF
rtn=GlobalFree(pi2_Memory)
IF rtn=0 THEN
pi2_mem=0
ELSE
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
ELSE
END IF
rtn=GlobalFree(jobs_Memory)
IF rtn=0 THEN
jobs_mem=0
ELSE
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
ELSE
END IF
rtn=GlobalFree(job_Memory)
IF rtn=0 THEN
job_mem=0
ELSE
END IF
END IF
END SUB
SUB UnLock_DefaultMemory
rtn=GlobalUnlock(FLock)
IF ((rtn=0) AND (GetLastError()=0)) THEN
ELSE
END IF
END SUB
SUB Free_DefaultMemory
rtn=GlobalFree(FLong)
IF rtn=0 THEN
ELSE
END IF
END SUB
SUB Free_pdMemory
IF pd_mem=1 THEN
rtn=GlobalUnlock(pd_Lock)
IF ((rtn=0) AND (GetLastError()=0)) THEN
ELSE
END IF
rtn=GlobalFree(pd_Memory)
IF rtn=0 THEN
ELSE
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
FFour=PSD_INTHOUSANDTHSOFINCHES OR PSD_MINMARGINS OR PSD_MARGINS OR PSD_DISABLEORIENTATION OR PSD_DISABLEPRINTER OR PSD_DISABLEPAPER
CopyMemory FInt+16, VARPTR(FFour), 4
FFour=0
CopyMemory FInt+20, VARPTR(FFour), 4
FFour=0
CopyMemory FInt+24, VARPTR(FFour), 4
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
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
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))
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
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
FFour=PD_SELECTION OR PD_COLLATE OR PD_PAGENUMS OR PD_PRINTTOFILE
CopyMemory FInt+20, VARPTR(FFour), 4
FWord=1
CopyMemory FInt+24, VARPTR(FWord), 2
FWord=6
CopyMemory FInt+26, VARPTR(FWord), 2
FWord=1
CopyMemory FInt+28, VARPTR(FWord), 2
FWord=9
CopyMemory FInt+30, VARPTR(FWord), 2
FWord=4
CopyMemory FInt+32, VARPTR(FWord), 2
rtn=PrintDlg(FInt)
IF rtn=1 THEN
CopyMemory VARPTR(FFour), FInt+20, 4
SHOWMESSAGE(HEX$(FFour))
CopyMemory VARPTR(FWord), FInt+24, 2
SHOWMESSAGE(HEX$(FWord))
CopyMemory VARPTR(FWord), FInt+26, 2
SHOWMESSAGE(HEX$(FWord))
CopyMemory VARPTR(FWord), FInt+32, 2
SHOWMESSAGE(HEX$(FWord))
ELSEIF rtn=0 THEN
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
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
CopyMemory VARPTR(FAdr), FInt, 4
FLen=LEN(VARPTR$(FAdr))
prt_Name$=STRING$(FLen, 0)
CopyMemory VARPTR(prt_Name$), FAdr, FLen
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
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()
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
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
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
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
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
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
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
ELSEIF rtn=90 THEN
ELSEIF rtn=270 THEN
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
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
ELSEIF rtn=1 THEN
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
ELSEIF rtn=1 THEN
prt_error=0
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
ELSE
prt_error=0
FOR count=0 TO rtn-1
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
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
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
IF (rtn AND DCTT_BITMAP)=DCTT_BITMAP THEN
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
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
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
END IF
END IF
END IF
END SUB
SUB Abort_Printer
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
FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 20)
IF FLong<>0 THEN
FInt=GlobalLock(FLong)
IF FInt<>0 THEN
FLock=FInt
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
jobID=StartDoc(prt_DC, FInt)
IF jobID>0 THEN
rtn=StartPage(prt_DC)
IF rtn>0 THEN
hsize=-MulDiv(36, GetDeviceCaps(prt_DC, LOGPIXELSX), 72)
wsize=-MulDiv(16, GetDeviceCaps(prt_DC, LOGPIXELSY), 72)
stg$="Futura Black BT"
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$))
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
rtn=EndDoc(prt_DC)
IF rtn>0 THEN
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
FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 20)
IF FLong<>0 THEN
FInt=GlobalLock(FLong)
IF FInt<>0 THEN
FLock=FInt
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
jobID=StartDoc(prt_DC, FInt)
IF jobID>0 THEN
rtn=StartPage(prt_DC)
IF rtn>0 THEN
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)
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
rtn=EndDoc(prt_DC)
IF rtn>0 THEN
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
FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 12)
IF FLong<>0 THEN
FInt=GlobalLock(FLong)
IF FInt<>0 THEN
FLock=FInt
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
rtn=SetJob(prt_Handle, jobID, 0, 0, JOB_CONTROL_PAUSE)
IF rtn<>0 THEN
Get_Job
FFour=67
CopyMemory job_Default+56, VARPTR(FFour), 4
rtn=SetJob(prt_Handle, jobID, 2, job_Default, JOB_CONTROL_RESUME)
IF rtn<>0 THEN
rtn=WritePrinter(prt_Handle, @raw_buffer(0), 1000, @rtnval)
IF rtn<>0 THEN
END IF
END IF
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
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
FLong=GlobalAlloc(GMEM_FIXED OR GMEM_ZEROINIT, 20)
IF FLong<>0 THEN
FInt=GlobalLock(FLong)
IF FInt<>0 THEN
FLock=FInt
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
jobID=StartDoc(prt_DC, FInt)
IF jobID>0 THEN
rtn=StartPage(prt_DC)
IF rtn>0 THEN
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
points(0)=0
points(1)=0
points(2)=0
points(3)=100
points(4)=100
points(5)=100
points(6)=100
points(7)=200
points(8)=200
points(9)=200
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
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
rtn=GetDeviceCaps(prt_DC, RASTERCAPS)
IF rtn<>0 THEN
bm_Window=GetDesktopWindow()
bm_DC=GetDC(bm_Window)
IF bm_DC<>0 THEN
Set_StretchMode(BLACKONWHITE)
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
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
rtn=EndDoc(prt_DC)
IF rtn>0 THEN
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
prt_Name$=Printer.Printers(1)
Open_Printer()
Create_DC()
Delete_DC
Close_Printer
|
|