WINPRINT-SET-CURSOR

This operation code allows you to change the position of the printer's write cursor. This is useful when doing multiple write statements that include a variety of fonts, font sizes, and font attributes.

Usage

CALL "WIN$PRINTER"
    USING WINPRINT-SET-CURSOR, WINPRINT-DATA
    GIVING RESULT

Parameters

WINPRINT-DATA Group item defined in winprint.def as follows:
01 WINPRINT-DATA.
   03 WPRTDATA-SET-STD-FONT.
   03 WPRTDATA-DRAW REDEFINES
   WPRTDATA-SET-STD-FONT.
      05  WPRTDATA-DRAW-START-X       PIC 9(7)V99 COMP-5.
      05  WPRTDATA-DRAW-START-Y       PIC 9(7)V99 COMP-5.
      05  WPRTDATA-DRAW-STOP-X        PIC 9(7)V99 COMP-5.
      05  WPRTDATA-DRAW-STOP-Y        PIC 9(7)V99 COMP-5.
      05  WPRTDATA-DRAW-UNITS         UNSIGNED-SHORT.
      05  WPRTDATA-DRAW-SHAPE         UNSIGNED-SHORT.

Return Values

This option returns the horizontal and vertical coordinates of the write cursor. If an error is returned, the current cursor position is not affected.

Description

When printing in Windows, the position of text on the printed page is determined by the location of the write cursor. This is usually handled automatically by the runtime, but you may use this operation to position the cursor yourself.

The printer must be open to perform this operation. WPRTDATA-DRAW should be initialized prior to use. The current cursor position on the printer is modified by this call only if WPRTDATA-DRAW-SHAPE is set to a value of 0 and the operation is successful. When the cursor is moved in this manner, subsequent WRITE statements will be affected. One exception is that the vertical position of subsequent calls to WINPRINT-COLUMNS will be altered, but not the horizontal position.

Note: When you call WINPRINT-SET-CURSOR, the operation will automatically test to see if a form feed is pending. If this is the case, the form feed will be performed before the call to this operation is executed.

If you use this operation with WPRDATA-DRAW-SHAPE set to a non-zero value, the cursor is not repositioned. This can be used to inquire the position of the write cursor without changing it. There is no limit to the number of times this operation may be called.

WINPRINT-SET-CURSOR has the following values:

  • WPRTDATA-DRAW-START-X - Specifies the X coordinate of the cursor location. The unit of measure is set with WPRTDATA-DRAW-UNITS. The minimum value of this coordinate is 0.
  • WPRTDATA-DRAW-START-Y - Specifies the Y coordinate of the cursor location. The unit of measure is set with WPRTDATA-DRAW-UNITS. The minimum value of this coordinate is 0.
  • WPRTDATA-DRAW-STOP-X - Returns the lower-right horizontal coordinate of the cursor location. This parameter has no input value, the previous X coordinate is returned. The unit of measure is determined by the setting of WPRTDATA-DRAW-UNITS.
  • WPRTDATA-DRAW-STOP-Y - Returns the lower-right vertical coordinate of the cursor location. This parameter has no input value, the previous Y coordinate is returned. The unit of measure is determined by the setting of WPRTDATA-DRAW-UNITS.
  • WPRTDATA-DRAW-UNITS - Specifies the unit of measure used for the values passed. If an illegal value is used, the default will be used (WPRTUNITS-PIXELS). The unit of measure may be set to one of the following values:
    WPRTUNITS-CELLS Values are measured using the cell size of the currently selected font. The cell-size is determined by the height and width of the 0 character of a font. This is roughly equivalent to measuring in characters.

    Positioning is relative to the individual printer's physical margin. Please note that the margin set in WINPRINT-SET-MARGINS is not used to determine the cursor position.

    If you use a proportional font, it is common for uppercase characters to be wider than this measurement. Non-integer values are allowed in the measurements.

    WPRTUNITS-CELLS-ABS Values are measured using the cell size of the currently selected font. Positioning is based on the left edge of the paper, regardless of the physical left margin determined by the printer (even if the absolute position is smaller). If the dimensions of the area to be printed are less than the printer's left or top physical margin, or greater than the printer's right or bottom physical margin, WIN$PRINTER will return an error. (Note that due to inherent differences in the hardware of printer manufacturers, this value may not provide truly device-independent results.)
    WPRTUNITS-INCHES Values are measured in inches. Positioning is relative to the individual printer's physical margin. Please note that the margin set in WINPRINT-SET-MARGINS is not used to determine the cursor position.
    WPRTUNITS-INCHES-ABS Values are measured in inches. Positioning is based on the left edge of the paper, regardless of the physical left margin determined by the printer (even if the absolute position is smaller). If the dimensions of the area to be printed are less than the printer's left or top physical margin, or greater than the printer's right or bottom physical margin, WIN$PRINTER will return an error.
    WPRTUNITS-CENTIMETERS Values are measured in centimeters. Positioning is relative to the individual printer's physical margin. Please note that the margin set in WINPRINT-SET-MARGINS is not used to determine the cursor position.
    WPRTUNITS-CENTIMETERS-ABS Values are measured in centimeters. Positioning is based on the left edge of the paper, regardless of the physical left margin determined by the printer (even if the absolute position is smaller). If the dimensions of the area to be printed are less than the printer's left or top physical margin, or greater than the printer's right or bottom physical margin, WIN$PRINTER will return an error.
    WPRTUNITS-PIXELS (default) Values are measured using the dots-per-inch (DPI) resolution of the output device. Only integer values are allowed in the measurements. Positioning is relative to the individual printer's physical margin. Please note that the margin set in WINPRINT-SET-MARGINS is not used to determine the cursor position.

    The actual size of this measurement varies depending on the target printer's resolution. This means that a coordinate of 5 will appear in a different location on a 300dpi printer than it will on a 600dpi printer. Consider the unit of measure relative to the resolution of the targeting printer before printing.

  • WPRTDATA-DRAW-SHAPE - Determines if subsequent WRITE statements will be affected. A value of 0 sets the position of the write cursor. A non zero value will simply return the coordinates of the current position of the write cursor. Return values are determined by the setting of WPRTDATA-DRAW-UNITS.
    Note: If you are using WPRDATA-DRAW-SHAPE to inquire the position of the write cursor, and WPRTDATA-DRAW-UNITS is set to a value other than WPRTUNITS-PIXELS, there is a possibility that the cursor position returned may not be 100% accurate, due to rounding errors.