xPrint.dll entry points
These entries are FREE. So you can use the vpxPrint DLL just for this!
getPrinterList |
get a list of installed printers |
•First parameter: length of the receiving area (LONG)
•Second parameter: memptr to this area. This return value is a comma-separated list of available printers.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getPrinterList( 1024, M).
L = get-String(M, 1).
Set-size(M) = 0.
getPrinterFonts |
get a list of printers fonts |
•First parameter: length of the receiving area (LONG)
•Second parameter : memptr to this area. This return value is a comma-separated list of available fonts for the current printer.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getPrinterFonts( 1024, M).
L = get-String(M, 1).
Set-size(M) = 0.
getScreenFonts |
get a list of screen fonts |
•First parameter: length of the receiving area (LONG)
•Second parameter: memptr to this area. This return value is a comma-separated list of available screen fonts.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getScreenFonts( 1024, M).
L = get-String(M, 1).
Set-size(M) = 0.
getTextWidth |
Length of text |
•First parameter: input Text
•Second parameter : font description. The font parameter is a comma-delimited list: <Font Name>,<Pitch>,[U,B,I]
•Third parameter: output returned length of the text in pixels.
def var myText as char initial "Here is my text." NO-UNDO.
def var myFont as char initial "Arial,14,B" NO-UNDO.
def var I as int NO-UNDO.
RUN getTextWidth( myText, myFont, output I). /* I = length in pixels */
If your program makes an extensive usage of the getTextWidth function, load the dll before your calls with a loadLibrary API call, don't forget to release it with a freeLibrary after your work. These entry points are defined in the xPrint.i file. Run loadxPrint or unloadxPrint.
Since the version 6.0, the xPrint.dll is persistent and loadxPrint is no more needed.
You can see this example in the xTest.w program.
getPrinterRes |
Printer resolution |
•First parameter: OUTPUT return value (LONG)
def var R as INT NO-undo.
run getPrinterRes( Output R).
fontDialog |
Displays the WINDOWS font dialog box. |
•First parameter: integer type of font: 1 = Screen font dialog, 2 = Printer font dialog, other values = screen + printer fonts,
•Second parameter: MEMPTR to return value. The return-value is structured as a LINE-FEED (chr(10)) delimited list:
| o | Entry(1, <areaName>, chr(10) ) = "Arial,10,B,U". This entry can be directly used as input for getTextWidth |
| o | Entry(2, <areaName>, chr(10) ) = "<Farial><P10><B><U>". This entry can be used for vpxPrint files (*.xpr). |
•Third parameter: return INTEGER(LONG) value : 0 = user has cancelled the dialog-box, 1 = OK
def var M as MEMPTR NO-undo.
def var dialogType as int no-undo.
def var returnCode as int no-undo.
def var L as char no-undo.
dialogType = 3. /* 1 = Screen fonts, 2 = Printer fonts, other = all */
set-size(M) = 512.
run fontDialog( dialogType, M, output returnCode).
L = get-String(M, 1).
set-size(M) = 0.
getTextHeight |
Height of text within a frame |
•First parameter: input Text
•Second parameter : font description. The font parameter is a comma-delimited list: Font Name,Pitch,[U,B,I,K]
•Third parameter: length in pixels of the receiving area
•Output : number of lines.
def var myText as char initial "Here is my text." NO-UNDO.
def var myFont as char initial "Arial,14,B" NO-UNDO.
Def var myWidth as int initial 600 NO-UNDO.
def var I as int NO-UNDO.
RUN getTextHeight( myText, myFont, myWidth, output I). /* I = # lines */
If your program makes an extensive usage of the getTextWidth function, load the dll before your calls with a loadLibrary API call, don't forget to release it with a freeLibrary after your work. This entry points are defined in the xPrint.i file. Run loadxPrint or unloadxPrint.
Since the version 6.0, the xPrint.dll is persistent and loadxPrint is no more needed.
You can see the full example in the xTest.w program.
You can use this function to determine the number of lines produced by a <FRAME#1><USE#1> xxx xxx xxxxxxxx sequence. When you send such text, vpxPrint smoothly prints the text in the area but you don't get the number of lines that vpxPrint writes.
Use getextHeight() to check the number of lines per page (overflow or bottom frame to print) or setting the next line number.
getImageDim |
get the image width and height (see the xPrint.i include getImageDim reference) |
•First parameter : image name
•Second parameter : width in pixels
•Third parameter : height in pixels
Example :
DEF VAR imageWidth AS INTEGER NO-UNDO.
DEF VAR imageHeight AS INTEGER NO-UNDO.
RUN getImageDim( "C:\TEMP\myImage.BMP",
input-output imageWidth,
input-output imageHeight).
•First parameter : integer font size.
•Second parameter : MEMPTR to CPI setting (vpxPrint tag string)
Example 1:
DEF VAR M AS MEMPTR.
DEF VAR L AS CHAR.
SET-SIZE(M) = 256.
run getCPI(8, M).
L = get-String(M, 1).
SET-SIZE(M) = 0.
in return L contains <CPI=15>
Example 2 :
To get all the CPI settings for font sizes varying from 2 to 20 :
DEF VAR C AS CHAR.
DEF VAR M AS MEMPTR.
DEF VAR I AS INT.
SET-SIZE(M) = 30.
REPEAT I = 2 TO 20:
RUN getCPI(I, OUTPUT M).
C = GET-STRING(M, 1).
DISPLAY I LABEL "Pitch" C LABEL "Tag" FORMAT "x(20)".
END.
SET-SIZE(M)= 0.
GetLPI |
get the number of lines per inch for a given font size. |
•First parameter : font description. The font parameter is a comma-delimited list : Font Name,Pitch,[U,B,I,K] (it's not the vpxPrint Form)
•Second parameter : MEMPTR to LPI setting (string)
Example :
DEF VAR M AS MEMPTR.
DEF VAR L AS CHAR.
SET-SIZE(M) = 256.
run getLPI('ARIAL,12,B', M).
L = get-String(M, 1).
SET-SIZE(M) = 0.
/* Now we can use '<LPI' + L + '>' as a normal setting for vpxPrint.
See the xTest.w, button Font dialog for an example.
*/
printerDialog |
displays a printer dialog box and returns a comma-separated list containing theprinter name, paper format name, dimensions, orientation, bin and copies number. |
•First parameter : comma-separated list area
7 entries : printer name,
Format name (see the list of supported formats by vpxPrint)
Width in tenth of millimeters,
Height in tenth of millimeters,
Orientation,
BIN=binName
COPIES=#ofCopies
Example :
DEF VAR M AS MEMPTR NO-UNDO.
DEF VAR A AS CHAR NO-UNDO.
SET-SIZE(M) = 256.
RUN printerDialog( M ).
A = GET-STRING(M, 1).
SET-SIZE(M) = 0.
MESSAGE "Printer name :" ENTRY(1, A)
SKIP
"Format Name :" ENTRY(2, A)
SKIP(1)
"Dim :" ENTRY(3, A) "x" ENTRY(4, A) "(tenth mm)"
SKIP
"Orientation :" ENTRY(5, A)
VIEW-AS ALERT-BOX INFO.
The getPrinter procedure returns the current attributes for the current printer without asking for a printer.
setPrinter |
Sets the current printer attributes. |
This entry can be used (for example) before a printerDialog for setting default values.
Remember that the DLL must stay in memory in order to save the current values between the different calls. This is achieved by loading vpxPrint (RUN loadxPrint) before the succession of calls.
PROGRESS users : since the version 6.0, the xPrint.dll is declared as persistent in { xPrint.i } and loadxPrint is no more needed.
•Parameter : printer attributes description, a comma delimited list with the following available keywords:
PRINTER= printerName
BIN= bin name or number
COPIES= number of copies
ORIENTATION= Portrait or Landscape
| FORMAT= | vpxPrint format : as the list is a comma delimited, if a custom size is to be specified, replace the commas in this entry by a ; |
Example:
FORMAT=CUSTOM;120;130
All parameters are optional, but at least specify one.
Images, WORD, EXCEL and other contents are supported. The WMF can then be imported within an vpxPrint report.
Two parameters:
| · | The output file name: must be a valid file name with a WMF extension |
| · | The return status: integer value |
Example:
DEF VAR L AS INT NO-UNDO. /* return status */
FILE-INFO:FILE-NAME = ".".
OS-DELETE VALUE( FILE-INFO:FULL-PATHNAME + "\clipboard.wmf" ) NO-ERROR.
RUN saveFromClipboard( FILE-INFO:FULL-PATHNAME + "\clipboard.wmf", OUTPUT L).
IF SEARCH( FILE-INFO:FULL-PATHNAME + "\clipboard.wmf") = ? THEN
MESSAGE "Image has not been created."
SKIP
"Please fill in the clipboard with an image" SKIP
"to test this function." VIEW-AS ALERT-BOX WARNING.
ELSE
MESSAGE FILE-INFO:FULL-PATHNAME + "\clipboard.wmf"
"has been created from Clipboard." VIEW-AS ALERT-BOX INFO.
pageCount |
retrieves the number of pages of a given file. |
If the file ends with a form-feed with no characters (except LF, CR or space) after it, the last page is not counted.
This procedure returns invalid value when orientation changes in the report.
Add to the result the number of orientation changes (<OPORTRAIT> or <OLANDSCAPE>)
Two parameters:
| · | The input file name: must be a valid full file name |
| · | The page count: integer value ( -1 if the file does not exist) |
| · |
Example:
DEF VAR N AS INT NO-UNDO. /* return value */
RUN pageCount( "c:\Temp\MyFile.xpr", OUTPUT N).
Two parameters:
•The input RTF sequence (character variable).
•The return value: MEMPTR value
Note:
This procedure processes strings and attributes (font, size, style, color) only.
It does not support indentation, bullets, justification and images.
Example:
DEF VAR inputRTF AS CHAR NO-UNDO.
DEF VAR M AS MEMPTR NO-UNDO.
SET-SIZE(M) = 60000. /* Allocate enough size */
/*
Put a valid RTF sequence in the inputRTF variable
=================================================
*/
RUN convertRTF( inputRTF, M).
L = GET-STRING(M, 1). /* M contains the vpxPrint tags */
SET-SIZE(M) = 0. /* Frees the MEMPTR memory */
OUTPUT STREAM I TO demoRTF.xpr.
PUT STREAM I CONTROL "<PREVIEW>"
"<#1><UNITS=mm><AT=250,190><FRAME#1><RECT#1><ALIGN=BASE><USE#1><AT=+5>"
L.
OUTPUT STREAM I CLOSE.
RUN printFile("demoRTF.xpr").
•One parameter: memptr to the area. This return value is the printer name.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getLastPrinter( M ).
L = get-String(M, 1).
Set-size(M) = 0.
MESSAGE "Last printer"
SKIP
L
VIEW-AS ALERT-BOX.
This entry can be used to define a new Windows default printer.
•Parameter : printer name
RUN setDefaultPrinter("Printername").
vpxPrint searches all available printers for a printer whose name equals to or begins by the specified printer name.
if no printer matches the specified name, no change occurs.
This entry can be used to get the name of the Windows default printer.
•One parameter: memptr to the area. The return value is the printer name.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 255.
run getDefaultPrinter( M ).
L = get-String(M, 1).
Set-size(M) = 0.
MESSAGE "Default printer"
SKIP
L
VIEW-AS ALERT-BOX.