DrawText Command

Purpose

Displays formatted text.

Syntax

DrawText x1, y1, x2, y2, t$, mode

x1, y1, x2, y2:floating-point exp
t$:sexp
mode:iexp

Description

DrawText works in principle like Text; however the text can be formatted by using the last parameter mode. It must be taken into account that Windows can clip text output to a rectangle. This occurs for example in multi-line Combo boxes. The formatted output is therefore limited to a rectangular area whose height (in case of single line text) is determined by the font height. The text specified in t$ is displayed at the output coordinates x and y. mode can assume the following values for a formatting with a logical Or:

DT_BOTTOM ($0008) draws a single line of text at the bottom of a rectangular area. This only works with single line text and must have the DT_SINGLELINE mode specified as well.
DT_CALCRECT ($0400) determines the width and height of a rectangular area.
DT_CENTER ($0001) centers text within a rectangular area.
DT_EXPANDTABS ($0040) expands the tab stops.
DT_EXTERNALLEADING ($0200) expands the height of a text line by the distance between two lines.
DT_LEFT($0000) draws text left justified.
DT_NOCLIP ($0100) turns the clipping to a rectangular area off.
DT_NOPREFIX ($0800) disables the default function of the "&" character (display the following characters as underlined.
DT_RIGHT ($0002) draws text right justified.
DT_SINGLELINE ($0020) specifies a single line of text.
DT_TABSTOP ($0080) sets tab stops. The high byte of attr% contains the number of characters per tab.
DT_TOP ($0000) draws a single line of text at the top edge of a rectangular area.
DT_VCENTER ($0004) displays a single line of text vertically centered. This only works with single line text and must have the DT_SINGLELINE mode specified as well.
DT_WORDBREAK ($0010) turns on word wrap.
DT_EDITCONTROL Duplicates the characteristics of a multi line edit control
DT_PATH_ELLIPSIS or DT_END_ELLIPSIS Replaces part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle. The given string is not modified unless the DT_MODIFYSTRING flag is specified.
DT_MODIFYSTRING Modifies the given string to match the displayed text. This flag has no effect unless the DT_END_ELLIPSIS or DT_PATH_ELLIPSIS flag is specified.
DT_RTLREADING Layout in right to left reading order for bi-directional text when the font selected into the hDC is a Hebrew or Arabic font. The default reading order for all text is left to right.
DT_WORD_ELLIPSIS Truncates text that does not fit in the rectangle and adds ellipses.

Note  The DT_CALCRECT, DT_EXTERNALLEADING, DT_INTERNAL, DT_NOCLIP, and DT_NOPREFIX values cannot be used with the DT_TABSTOP value.

Example

OpenW # 1

Local a$ = "Hello" + Chr$(13) + "Bye..."

DrawText 10, 20, 110, 120, a$, DT_NOCLIP | DT_WORDBREAK

Prints "Hello" and then on the next line "Bye", ignoring the clipping rectangle.

Remarks

DrawText corresponds to Windows function DrawText.

See Also

Text, GrayText

{Created by Sjouke Hamstra; Last updated: 03/10/2014 by James Gaite}