Home > Language Reference > Classes > Display

TextOut Method

Draw text.

Syntax

Public Function TextOut(ByVal x As Integer, ByVal y As Integer, ByRef sText As String, Optional ByVal eAlign As HbTextAlign = hbTextAlignLeft+hbTextAlignTop, Optional ByVal iWidth As Integer = 32767) As Integer

ParameterDescription
xX-coordinate.
yY-coordinate.
sTextText to display.
eAlignAlignment options.
iWidthMaximum width of the text to be drawn.

Remarks

The TextOut method displays text at the (x, y) coordinates specified. The characters are drawn using the text color specified by the TextColor property, whilst the space between the characters is filled using the background color specified by the BackColor property. If necessary, the text is underlined using the foreground color specified by the ForeColor property. The font as well as the underlining options are specified by the DrawFont and ScaleFont properties.

If drawing all the specified text requires more than the iWidth parameter allows, this function draws one less than the number of characters that can fit in the specified width, and then draws an ellipsis (...) in the remaining space.

The eAlign parameter specifies the way that the text should be aligned relative to the x and y coordinates. It should be a combination of the following constants:

To indicate the horizontal alignment, specify one of the following constants:

Constant Value Description
hbTextAlignLeft&H0000The parameter x specifies the coordinate of the left handside of the text.
hbTextAlignCenter&H0001The parameter x specifies the coordinate of the center of the text.
hbTextAlignRight&H0002The parameter x specifies the coordinate of the right handside of the text.

To indicate the vertical alignment, specify one of the following constants:

ConstantValueDescription
hbTextAlignTop&H0000The parameter y specifies the coordinate of the top edge of the text.
hbTextAlignVCenter&H0010The parameter y specifies the coordinate of the center edge of the text.
hbTextAlignBottom&H0020The parameter y specifies the coordinate of the bottom edge of the text.

The returned value is the width of the drawn text. This value is always less than the width specified by the iWidth parameter, and includes the width of the ellipsis, if present.

Before drawing the text, the graphics instruction buffer is emptied by an implicit call to the Flush method, then the text is displayed.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A