Drawing formatted text (DrawFormattedText)ΒΆ

DrawFormattedText()

Draw formatted text


SYNTAX

DrawFormattedText(window_id, xpos, ypos, text, font, width, height, format)

Draw a piece of text at a specified location in a window or report. This function can format text on a single line or wrap it over multiple lines.

This function is similar to DrawText(), but offers more powerful formatting options.

The function returns the height of the text unless either of the format flags DT_VCENTRE or DT_BOTTOM is specified. In this case, the return value is the offset from ypos to the bottom of the text. The return value is in the same unit as was used to specify xpos, ypos, width and height.

window_id

The identifier of the window in which the text is to be placed. To print it in the current report, specify NULL instead of a window_id.

xpos, ypos

The x and y co-ordinates of the top left corner of the rectangle into which text is to be formatted. The size of the rectangle is specified in the width and height parameters. Co-ordinates are measured in the unit specified in sys.Unit. If sys.Unit is not set, device units are used.

text

The text to be drawn. It can be a field, an expression or a quoted string.

font

The font parameter requires the same syntax as a window or control font clause. Unless a valid font specification is provided, the default specified in Section 1.4 (Default font) of the terminal parameter file is used. The standard terminal parameter file for all versions of Windows is $SCULPTOR/term/mswin.s. See Terminal parameter files. If no default font is defined, then Courier New@10 (Courier New, 10 point) is used as the default.

width
height

The width and height of the rectangle into which the text is to be formatted. These parameters must be supplied. Width and height are measured in the unit specified in sys.Unit. If sys.Unit is not set, device units are used.

format

Format flags. The available flags are defined under Format flags in $SCULPTOR/include/draw.h. Multiple flags must be separated by the ! character. See the MSDN Library documentation on the DrawText function for further information on these flags.


NOTES

  • The getprintxy() and setprintxy() functions are available to help with positioning when draw functions are mixed with Sculptor print[h] commands.

  • Since xpos and ypos refer to a rectangle that can span more than one line, this function sets the text alignment flags TA_TOP and TA_LEFT, and restores the previous flag settings when finished. Text alignment flags are provided for use with the DrawText() function.

Since these two flags are always set, text drawn by DrawFormattedText() in a report will be positioned roughly one line lower than text drawn at the same ypos co-ordinate using DrawText() and default alignment.


EXAMPLE

!temp xpos,,i4
!temp ypos,,i4
!temp yinc,,i4

    getprintxy(xpos, ypos)

    yinc = DrawFormattedText(NULL, xpos, ypos, Address, "Times New Roman@12", \
        35 * sys.AvgCharWidth, 6 * sys.LineHeight, DT_WORDBREAK_EDITCONTROL)

    setprintxy(xpos, ypos + yinc)

RELATED TOPICS

Drawing operations

Draw functions

DrawText()