PrinterCE
SDK Special Topics
.Net CF C# or VB.Net: Printing Utilities |
PrinterCE
Developer's Guide
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PrinterCE:
The primary control for printing text, images, drawing objects (lines,
rectangles, and so on) and much more. | |
| AsciiCE2:
A separate control that allows for printing pure ASCII text to any
ASCII printer. | |
| PrintDC : Emulates the standard Windows printing process for C/C++/MFC developers porting existing Windows apps. | |
| BarcodeCE: An optional control that adds over a dozen barcode types to the PrinterCE toolkit. |
READ-ONLY property returns string describing this version of
PrinterCE/AsciiCE/BarcodeCE.
MFC Syntax:
Cstring str =PrinterCE1.GetAbout();
C++ Syntax: PrinterCE1.get_About(BSTR* str);
eVB
Syntax: str=PrinterCE1.About
String describing this version of PrinterCE - including
information on WinCE platform (Pocket PC, HPC/Pro), processor type and
version. This string can be used in a MsgBox() to display the information.
READ-ONLY property returns bit-values that identify all the
capabilities in the current control.
MFC Syntax:
long bitvals =PrinterCE1.GetCapabilities();
C++ Syntax: PrinterCE1.get_Capabilities(long * bitvals);
eVB
Syntax: bitvals =
PrinterCE1.Capabilities
Bit values that identify the capabilities of the current
control:
|
Constant |
Setting |
Description |
|
CAPS_STD |
01h |
PrinterCE Standard capabilities |
|
CAPS_PLUS |
02h |
PrinterCE SDK |
|
CAPS_ASCII |
04h |
AsciiCE |
|
CAPS_BARCODE |
08h |
BarcodeCE |
CAPS_ASCII2 |
10h |
AsciiCE2 |
|
CAPS_PRINTDC |
20h |
PrintDC |
This method converts a value from one ScaleMode system to
another.
MFC Syntax:
float toval=PrinterCE1.ConvertCoord(float fromval, long fromscale,
long toscale);
C++ Syntax:
PrinterCE1.ConvertCoord(float fromval, long fromscale, long
toscale,float* toval);
eVB
Syntax:
toval = PrinterCE1.DrawConvertCoord fromval, fromscale, toscalee
fromval - Value to be converted
fromscale - "convert from" ScaleMode
toscale - "convert to" ScaleMode.
toval - Converted value.
To convert 1.25 inches into printer resolution: PrResVal=PrCE1.ConvertCoord(1.25,vbInches,vbPixels)
This method prints a circle or ellipse on a page.
MFC Syntax:
PrinterCE1.DrawCircle(float x, float y,float rad, VARIANT* color,
VARIANT* aspect);
C++ Syntax:
PrinterCE1.DrawCircle(float x, float y,float rad, VARIANT* color,
VARIANT* aspect);
eVB Syntax: PrinterCE1.DrawCircle x,
y, [color], [aspect]
x - Horizontal coordinate for the center point of a circle.
y - Vertical coordinate for the center point of a circle.
radius - Radius of a circle.
color – Optional - RGB color of a circle's outline. If omitted (or
NULL), the ForeColor value is used.
aspect – Optional - aspect ratio of a circle. The default value is 1.0,
which yields a perfect circle. Other values draw an ellipse. (Also see
DrawEllipse for another way to draw ellipses).
The ScaleMode property of object determines the units of
measure used. The FillColor and FillStyle properties of object determine
how a circle is filled.
The DrawWidth property determines the width of the line used to draw a
circle.
This method prints an ellipse on a page.
MFC Syntax:
PrinterCE1.DrawEllipse(float x1, float y1, float x2, float y2,
VARIANT* color);
C++ Syntax:
PrinterCE1.DrawEllipse(float x1, float y1, float x2, float y2,
VARIANT* color);
eVB
Syntax: PrinterCE1.DrawEllipse x1, y1, x2, y2, [color]
x1, y1, x2, y2 - Required. Values define a rectangle (x1,y1)
as one corner and (x2,y2) as opposing corner. An ellipse is drawn that
just fits within this bounding rectangle. .
color – Optional - RGB color of a circle's outline. If omitted, the
ForeColor value is used.
The ScaleMode property of object determines the units of
measure used. The FillColor and FillStyle properties of object determine
how a circle is filled.
The DrawWidth property determines the width of the line used to draw a
circle.
This method draws lines and rectangles on a Form.
MFC Syntax:
PrinterCE1.DrawLine(float x1, float y1, float x2, float y2,
VARIANT* color, VARIANT* boxfill);
C++ Syntax:
PrinterCE1.DrawLine(float x1, float y1, float x2, float y2,
VARIANT* color, VARIANT* boxfill);
eVB
Syntax: PrinterCE1.DrawLine x1,
y1, x2, y2, [color], [boxfill]
x1, y1 - starting coordinates for a line or rectangle
x2, y2 - ending coordinates for a line or rectangle.
color – Optional - RGB color used to draw a line. If omitted/NULL, the
ForeColor value is used.
boxfill – Optional – If omitted or NULL, simple line is drawn. if =
vbLineBox causes a box to be drawn using the coordinates to specify
opposite corners of the box. vbLineBoxFill specifies that the box is
filled with the same color used to draw the box. (See DrawRect and
DrawRoundedRect for other ways to draw rectangles)
The DrawWidth property determines the width of the line. The
ScaleMode property determines the unit of measure used.
| boxfill | Value | |
|
vbLineBox |
1 | Draws box using coords as opposite corners |
| vbLineBoxFill | 2 | Draws box and fills with line color |
This method prints a BMP, JPG, GIF or PNG
image file on the page.
MFC
Syntax:
PrinterCE1.DrawPicture(
C++ Syntax:
PrinterCE1.DrawPicture(BSTR picture,float x,float y,VARIANT*
width,VARIANT* height,VARIANT* keepaspect);
eVB Syntax:
PrinterCE1.DrawPicture picture, x, y, [width], [height], [keepaspect]
picture
: Path & filename of the image to be drawn.
x,y : Coordinates where picture will be drawn (in ScaleMode units). By
default, x,y is the top/left corner of the image location. Use
JustifyHoriz/JustifyVert to change this to Center or Bottom/Right.
width : Optional destination width of picture. If omitted or if zero, the
actual image width is used.
height : Optional destination height of picture. If omitted or if zero,
the actual image height is used.
keepaspect :
|
keepaspect value |
Description |
|
TRUE |
Aspect Ratio (width to height of original image is retained. Image is sized to fit inside area of "width" x "height" |
|
FALSE (default) |
Image is stretched or scrunched to fit within "width" x "height" |
|
2 |
Returns actual width and height of image in "width" and "height" values... NO PICTURE IS DRAWN!. Uses ScaleMode to determine unit of measure for width & height values. Input values for x, y, width and height are not used when determining and returning image width and height. |
If width and/or height are negative values, DrawPicture
creates a mirror image along the vertical axis (if width is negative)
and/or the horizontal axis (if height is negative).
This method draws a point on the page.
MFC Syntax:
PrinterCE1.DrawPoint(float x, float y,VARIANT* color);
C++ Syntax:
PrinterCE1.DrawPoint(float x, float y,VARIANT* color);
eVB
Syntax: PrinterCE1.DrawPoint x, y, [color]
x, y - Coordinates of the point to draw (in ScaleMode units)
color - Optional. RGB color for point. If omitted/NULL, the current
ForeColor value setting is used.
The setting of the DrawWidth property determines the size of
the point.
This method draws a rectangle on a page.
MFC Syntax:
PrinterCE1.DrawRect(float x1, float y1, float x2, float y2,
VARIANT* color);
C++ Syntax:
PrinterCE1.DrawRect(float x1, float y1, float x2, float y2,
VARIANT* color);
eVB
Syntax: PrinterCE1.DrawRect
x1, y1, x2, y2, [color]
x1, y1, x2, y2 - defines a rectangle with (x1,y1) as one
corner and (x2,y2) as opposing corner
color – Optional - RGB color of rectangle’s outline. If omitted/NULL,
the ForeColor value is used
Coordinates are in ScaleMode units. FillColor and
FillStyle properties of object determine how a rectangle is filled. The
DrawWidth property determines the width of the line used to draw a
rectangle.
This method draws a rectangle with rounded corners on a page.
MFC Syntax:
PrinterCE1.DrawRoundedRect(float x1, float y1, float x2, float y2,
float cornerwidth, float cornerheight, VARIANT* color);
C++ Syntax:
PrinterCE1.DrawRoundedRect(float x1, float y1, float x2, float y2,
float cornerwidth, float cornerheight, VARIANT* color);
eVB Syntax: PrinterCE1.
DrawRoundedRect x1,y1,x2,y2,cornerwidth,cornerheight, [color]
x1, y1, x2, y2 - Defines a rectangle with (x1,y1) as one
corner and (x2,y2) as opposing corner.
cornerwidth,cornerheight - defines the width and height of the curve of
the rounded rectangle..
color - Optional. RGB color of a rectangle’s outline. If omitted/NULL,
the ForeColor value is used.
Coordinates are in ScaleMode units. FillColor and FillStyle properties of object determine how a rectangle is filled. The DrawWidth property determines the width of the line used to draw a rectangle.
This method draws text on the page.
MFC Syntax:
PrinterCE1.DrawText(LPSTSTR str, VARIANT* x VARIANT* y, VARIANT*
count);
C++ Syntax:
PrinterCE1.DrawText(BSTR str, VARIANT* x VARIANT* y, VARIANT*
count);
eVB
Syntax: PrinterCE1.DrawText
string, [x], [y], [count]
string - Text to be drawn.
x, y - Optional. Coordinates of the text to be drawn. If not specified or
NULL, string is drawn at the intrinsic (TextX,TextY) coordinates.
count - Optional. Number of characters in "string" that should
be printed – if not specified or NULL then entire line of text is drawn.
The font properties of the PrinterCE control determines the
appearance of the text. The ForeColor property determines the color of the
text. After the text is drawn, TextX, TextY are updated so that the next
DrawText command will print on a new line. The JustifyHoriz, JustifyVert,
and Rotation properties all impact how and where the text is actually
drawn on the page. Coordinates are in ScaleMode units
This property returns and sets the line width for output from
a graphics method.
MFC Syntax:
float size =PrinterCE1.GetDrawWidth();
PrinterCE1.SetDrawWidth(float size);
C++ Syntax:
PrinterCE1.get_DrawWidth(float * size);
PrinterCE1.put_DrawWidth(float size);
eVB
Syntax: PrinterCE1.DrawWidth
[=size]
size –Value for the width of the line in the current
ScaleMode. For example, if ScaleMode is set to Inches, size of 0.1 would
select a line width of 1/10 of an inch. A size of 0 sets line width to 1
pixel.
This method causes the current page to be printed and resets
printing properties to default.
MFC Syntax:
PrinterCE1.EndDoc();
C++ Syntax:
PrinterCE1.EndDoc();
eVB
Syntax: PrinterCE1.EndDoc
Causes the current page to be printed and then resets all properties to their default settings. See also "NewPage".
This property returns and sets the color used to fill in
graphics methods: DrawRect, DrawRoundedRect, DrawCircle and DrawEllipse.
MFC Syntax:
long value =PrinterCE1.GetFillColor();
PrinterCE1.SetFillColor(long value);
C++ Syntax:
PrinterCE1.get_FillColor(long * value);
PrinterCE1.put_FillColor(long value);
eVB
Syntax: PrinterCE1.FillColor
[=value]
value - Standard RGB color value that determines the fill
color. By default, FillColor is set to 0 (Black).
When the FillStyle property is set to Transparent (default),
the FillColor setting is ignored. The valid range for a normal RGB color
is from 0 through 16,777,215 (&HFFFFFF). The high byte of a number in
this range equals 0. The lower 3 bytes, from least to most significant
byte, determine the amount of red, green, and blue, respectively. The red,
green, and blue components are each represented by a number from 0 through
255 (&HFF).
This property returns and sets the pattern used to fill in
graphics methods: DrawRect, DrawRoundedRect, DrawCircle and DrawEllipse.
MFC Syntax:
long value =PrinterCE1.GetFillStyle();
PrinterCE1.SetFillStyle(long value);
C++ Syntax:
PrinterCE1.get_FillStyle(long * value);
PrinterCE1.put_FillStyle(long value);
eVB
Syntax: PrinterCE1.FillStyle
[=value]
value - Integer that specifies the fill style. The following
table describes the settings for number.
|
Constant |
Setting |
Description |
|
|
picFSSolid |
0 |
Solid |
|
|
picFSTransparent |
1 (default) |
Transparent |
|
When the FillStyle property is set Transparent, the FillColor
setting is ignored.
This property returns and sets the Bold font style.
MFC Syntax:
long value =PrinterCE1.GetFontBold();
PrinterCE1.SetFontBold(long value);
C++ Syntax:
PrinterCE1.get_FontBold(long * value);
PrinterCE1.put_FontBold(long value);
eVB
Syntax: PrinterCE1.FontBold
[=value]
value - Boolean expression that specifies the font style.
Following are the settings for Boolean:
True - Turns on Bold formatting, False - Turns
off Bold formatting.
Sets the "current font settings" to Bold or Normal.
For more selective settings, see FontBoldVal property.
This property returns and sets the Bold font style.
MFC Syntax:
long value =PrinterCE1.GetFontBoldVal();
PrinterCE1.SetFontBoldVal(long value);
C++ Syntax:
PrinterCE1.get_FontBoldVal(long * value);
PrinterCE1.put_FontBoldVal(long value);
eVB
Syntax: PrinterCE1.FontBoldVal
[=value]
value - Integer value between 0 and 1000 to set the weight of
the font. Normal weight setting is 400 and standard Bold is 700.
Sets the "current font settings" to selected
weight..
This property returns and sets the Italic font style.
MFC Syntax:
long value =PrinterCE1.GetFontItalic();
PrinterCE1.SetFontItalic(long value);
C++ Syntax:
PrinterCE1.get_FontItalic(long * value);
PrinterCE1.put_FontItalic(long value);
eVB
Syntax: PrinterCE1.FontItalic
[=value]
value - Boolean expression that specifies the font style.
Following are the settings for Boolean:
True - Turns on the formatting in that style, False - Turns off the
formatting in that style (default)
Use these font properties to format text.
This property returns and sets the font used to print text..
MFC Syntax:
Cstring font =PrinterCE1.GetFontName();
PrinterCE1.SetFontName(
C++ Syntax:
PrinterCE1.get_FontName(BSTR* font);
PrinterCE1.put_FontName(BSTR font);
eVB
Syntax: PrinterCE1.FontName
[=font]
font - String expression that specifies the font name to use.
Any TrueType font can be used. To install a TrueType font to the device, simply copy from desktop PC to \Windows\Fonts folder on the device. You can use Pocket Word -> Edit -> Format -> pull down list of available fonts to see exact font names of all installed fonts.
This property returns and sets the size of the font to be used for printing.
MFC Syntax:
long value =PrinterCE1.GetFontSize();
PrinterCE1.SetFontSize(long value);
C++ Syntax:
PrinterCE1.get_FontSize(long * value);
PrinterCE1.put_FontSize(long value);
eVB
Syntax: PrinterCE1.FontSize
[=value]
value – Numeric expression that specifies the font size, in
points, to use.
Note: to match a point size with equivalent point size of Microsoft Word, use negative point size... for example, to match Word's 12 point font, use PrinterCE1.FontSize = -12.
The maximum value for FontSize is 2,160 points. The minimum
value is 4 points.
This property returns and sets the Strikethrough style.
MFC Syntax:
long value =PrinterCE1.GetFontStrikethru();
PrinterCE1.SetFontStrikethru(long value);
C++ Syntax:
PrinterCE1.get_FontStrikethru(long * value);
PrinterCE1.put_FontStrikethru(long value);
eVB
Syntax: PrinterCE1.FontStrikethru
[=value]
value - Boolean expression specifying the font style.
Following are the settings for Boolean:
True - Turns on the strike-through formatting. False - Turns off the
strike-through formatting (default)
This property returns and sets the Underline font style.
MFC Syntax:
long value =PrinterCE1.GetFontUnderline();
PrinterCE1.SetFontUnderline(long value);
C++ Syntax:
PrinterCE1.get_FontUnderline(long * value);
PrinterCE1.put_FontUnderline(long value);
eVB
Syntax: PrinterCE1.FontUnderline
[=value]
value - Boolean expression that specifies the font style.
Following are the settings for Boolean:
True - Turns on the underline formatting. False - Turns off
the underline formatting (default)
This property returns and sets the foreground color used to
print text.
MFC Syntax:
long value =PrinterCE1.GetForeColor();
PrinterCE1.SetForeColor(long value);
C++ Syntax:
PrinterCE1.get_ForeColor(long * value);
PrinterCE1.put_ForeColor(long value);
eVB
Syntax: PrinterCE1.ForeColor
[=value]
value – RGB color value. Default color is set to Black.
The valid range for a normal RGB color is from 0 through
16,777,215 (&HFFFFFF). The high byte of a number in this range equals
0. The lower 3 bytes, from least to most significant byte, determine the
amount of red, green, and blue, respectively. The red, green, and blue
components are each represented by a number from 0 through 255 (&HFF).
READ-ONLY Property - Returns the height of the given text
string (in ScaleMode units)
MFC Syntax:
float value =PrinterCE1.GetGetStringHeight(
C++ Syntax:
PrinterCE1.get_GetStringHeight(BSTR string, float* value);
eVB
Syntax:
value=PrinterCE1.GetStringHeight(string)
string – Text string
value – returns height of text string for currently
selected font in ScaleMode units
READ-ONLY Property - Returns the width of the given text
string (in ScaleMode units)
MFC Syntax:
float value =PrinterCE1.GetGetStringWidth(
C++ Syntax:
PrinterCE1.get_GetStringWidth(BSTR string, float* value);
eVB
Syntax: value=PrinterCE1.GetStringWidth(string)
string – Text string