SetDefaultPrinter |
Selects the default printer. The selection will be printer, to be connected, in call to
GetPrinterDC with NoChoce set to 'True'.
If you know, which printer and connection want to use, then use older way to connect but
do not forget to check values in source code correspond to the
currently connected printer, especially the connection string (do not change others,
if you do not know what you do)!
|
Usage:
If Not SetDefaultPrinter () Then MessageBox("Fail to select default printer!"): Exit
|
|
GetPrinterDC/Ex |
Prepare usage of the printer. Invoke it before use the printer directly.
Check returned value and NEVER forget to call appropriate DeleteDC/Ex.
If you don't want to use SetDefaultPrinter, then
never forget to check values in source code correspond to the
currently connected printer, especially the connection string (do not change others,
if you do not know what you do) and restore usage of old way by uncomment some source lines!
Pass the parameter 'False' to view printer dialog and allow changing of some default settings.
Note: the connection string MUST be the same with one,
used in Printer Applet.
Examples: "IRDA", "COM1: 9600", "COM1: 57600" or "COM1: 115200".
|
Usage:
Dim dc as Long
dc = GetPrinterDC (True)
If dc = 0 Then MessageBox("Fail to connect with printer!"): Exit
|
|
PrintText |
Enable print WYSIWYG text. The text is printed with the passed point size (not the pixel size!).
You can change foreground color, and/or width of font, and/or font name via parameters.
If you want to change background color you need to modify source code.
Horizontal align defaults to left. Width of the fonts can vary (see FW_ constants)
but not all widths produce different output (this is a WinCE limitation).
Font name defaults to 'Tahoma' and no other choices on many PDAs. The length
of text if limited by OS and used controls (probably 32Kb is the length limit).
Note: the text will be followed by feed defined in Printer Applet.
|
Usage: If Not PrintText (TextToPrint, 18, 0, False, False, False, False) Then
MessageBox("Fail to print text! Check the printer connection and paper."): Exit
|
|
PrintGraphic |
Enable print of WinCE HBITMAP. To load raster image of .BMP, .JPG, .GIF, .PNG and some
other file formats use SHLoadImageFile function. If function return 0 then given
file name is not recognized as valid raster format. There is no stretch options
i.e. image will fit whole page.
Note: the graphic will be followed by feed defined in Printer Applet.
|
Usage:
Dim bmp As Long
bmp = SHLoadImageFile (FileName)
If bmp = 0 Then Exit
If Not PrintGraphic (bmp) Then MessageBox("Fail to print graphic! Check the
printer connection and paper."): Exit
|
|
PrintWindow |
Enable print of WinCE HWND. Allows printing of a window's content, stretching it
to the current printer width. The transparent color is discarded when printing,
if there is no need of transparent color pass -1.
Note:
it's very important to set focus to the requested control!
0 HWND is the whole desktop.
The graphic will be followed by feed defined in Printer Applet.
|
Usage:
someControl.SetFocus
If Not PrintWindow (GetFocus, someControl.BackColor) Then MessageBox("Fail to
print window! Check the printer connection and paper."): Exit
|
|
DefinePrinterLogo |
Enable to define WinCE HBITMAP as printer's logo.
All limitations and features are the same as PrintGraphic,
plus additional limitations comes from the printer: the image can not exceed
384 pixels width (which is the fixed printer's width) and 248 pixels height.
The image is threated as true-color. Every pixel is converted to gray level (0-255),
and the levels bellow 128 are treated as black, all others are threated as white.
If the dimensions are out of permited, the downloading is not performed.
Note: the process of converting color image to monochrome is very slow.
Command to print logo is GS / n, where n (0-3) defines printing mode.
See WritePrinterDirect.
|
Usage:If Not DefinePrinterLogo(LogoBMP) Then MessageBox("Fail to define logo!"): Exit
|
|
ReadMagstripe |
Read magnetic card (if the environment exist; check via function ReadPrinterCaps
for the CAPS_MAGSTRIPE value).
If you want to read three tracks at once, check for the CAPS_THREE_HEAD value, otherwise
command will be reject by the printer. Successful reading is indicated by returned values,
if nothing is returned, the timeout has expired.
|
Usage:
Dim Track1 As String
Dim Track2 As String
Track1 = String(1, 0) ' all but zero length
Track2 = String(1, 0) ' all but zero length
If Not ReadMagstripe(Track1, Track2, "") Then MessageBox("MCR timeout expire! Try again or reject.")
|
|
PrintBarcode |
Allow printing barcodes. Pass the barcode data itself, some of the BARCODE_ type, the width,
the height, the font, the text position and the feed after printed barcode.
The barcode data must be proper, if it is not, or the barcode
is not fit in printer width (48mm) it will not be printed without notification of that.
Change the barcode width by BARCODE_WIDTH_ constants, and/or the duplicate text positions
by BARCODE_TEXTS_ constants, and/or the font, and/or the width by BARCODE_WIDTH_ constants.
|
Usage: If Not PrintBarcode ("123456789012", BARCODE_EAN13, BARCODE_WIDTH_NORMAL, 100, False, BARCODE_TEXTS_BOTH, 77)
Then MessageBox("Fail to print barcode! Check printer connection and paper."): Exit
|
|
ReadPrinterStatus |
Allows checking the printer about some conditions, see STATUS_ constants.
Use it to ensure that PP55 printer is properly connected.
|
Usage: If Not ReadPrinterStatus(Status) Then MessageBox("Fail to read status from printer!"): Exit
|
|
ReadPrinterInfo |
Allows checking the printer's battery voltage and head temperature. Voltages above
6.0V are functional for the printer, otherwise any attempt to print will turn off the
printer. The temperature of the printing head is measured in Celsius (if the CAPS_FAHRENHEIT
then in Fahrenheit) degree. The voltage value is multiplied by 10.
Can be used to ensure that the PP55 printer is properly connected.
|
Usage: If Not ReadPrinterInfo(Temp, Volt) Then MessageBox("Fail to read info from printer!"): Exit
|
|
ReadPrinterCaps |
Allows to check the printer about some equipment and features (see CAPS_ constants)
and to retrieve the printer's internal name (including version number and language version).
The name is composed from 27 character name (space padded) and three-digit number
without dot (where the first digit is major firmware version, next two digits are
minor version), followed by two-letter language code (EN stay for English, JP for Japan,
and so on).
Use it to ensure that PP55 printer is properly connected.
|
Usage: If Not ReadPrinterCaps(Caps, Name) Then MessageBox("Fail to read info from printer!"): Exit
|
|
ControlPassthrough |
Activates or deactivates passthrough mode.
|
Usage: .... ControlPassthrough (dc, True) - no command will accept by printer and RS line
can be used by other(s) .... If ControlPassthrough (dc, False) Then ... commands
are accepted again...
|
|
ForceClosePrinter |
Use to disconnect printer placed in passthrough mode. DeleteDC is called internaly by function.
Using it in other conditions can discard some printing.
|
Usage: ForceClosePrinter(dc). Check of returned value is redundant.
|
|
WritePrinterDirect |
Writes data directly to the printer. You must know the printer commands, or the data will
be treated as text and will be printed with the printer's internal font.
It is a low level function, so it is not recommended for use.
|
Usage:
Dim Cmd As String
Cmd = ByteToMemoryString(27) &
ByteToMemoryString(Asc("J")) &
ByteToMemoryString(100)
WritePrinterDirect(dc, Cmd, 3) will feed printer by 100/203 of inch.
|
|
ReadPrinterDirect |
Reads data from the printer. You must know what exactly will come from the printer or
the module will sleep until timeout expires.
It is a low level function, so it is not recommended for use.
|
Usage:
....
Dim Cmd As String
Cmd = ByteToMemoryString(27) &
ByteToMemoryString(Asc("v"))
If Not WritePrinterDirect(dc, Cmd, 2) Then Exit - pass status command
Dim Sz As Long
Sz = ReadPrinterDirect(dc, Cmd)
If Sz <> 1 Then Exit
....Cmd will contain one byte status from printer.
|
|