Skip to main content
Pie
ra0

TcxCanvas.DrawTexT(string,TRect,Integer,Boolean,TcxRotationAngle) Method

Draws formatted text within a specified rectangle on the canvas.

Declaration

procedure DrawTexT(const Text: string; R: TRect; Flags: Integer; Enabled: Boolean; ARotationAngle: TcxRotationAngle); overload;

Parameters

Name Type Description
Text string

A text string to display.

R TRect

The target rectangle on the canvas.

Flags Integer

A set of formatting flags.

Enabled Boolean

Specifies the Enabled state of the displayed text string.

ARotationAngle TcxRotationAngle

Enumerates predefined rotation angles.

Remarks

Call this procedure and pass a text string as the Text parameter to draw the string within a rectangle passed as the R parameter. The DrawTexT procedure uses the background color and font settings of the canvas to draw text.

You can pass False as the optional Enabled parameter to draw text for the disabled state of UI elements.

Use the optional ARotationAngle parameter to rotate the displayed text by a predefined angle.

The Flags parameter accepts any combination of the following text draw mode flags:

Flag

Description

cxAlignBottom

Aligns text to the bottom of the target rectangle if the cxSingleLine flag is also set.

This flag corresponds to the DT_BOTTOM flag in an underlying GDI DrawText function call.

cxAlignCenter

Centers text within the target rectangle. This flag replaces a combination of the cxAlignHCenter and cxAlignVCenter flags.

cxAlignHCenter

Centers text horizontally within the rectangle.

This flag corresponds to the DT_CENTER flag in an underlying GDI DrawText function call.

cxAlignLeft

Aligns text to the left border of the target rectangle.

This flag corresponds to the DT_LEFT flag in an underlying GDI DrawText function call.

cxAlignRight

Aligns text to the right border of the target rectangle. This flag is ignored if the displayed text string is broken into multiple lines.

This flag corresponds to the DT_RIGHT flag in an underlying GDI DrawText function call.

cxAlignTop

Aligns text to the top border of the target rectangle. This flag is ignored if the displayed text string is broken into multiple lines.

This flag corresponds to the DT_TOP flag in an underlying GDI DrawText function call.

cxAlignVCenter

Centers text vertically within the target rectangle. This flag is ignored if the displayed text string is broken into multiple lines.

This flag corresponds to the DT_VCENTER flag in an underlying GDI DrawText function call.

cxDontBreakChars

Forces the DrawText procedure to retain a partially visible last text line. Otherwise, the clipped text line is hidden. The cxDontBreakChars flag is ignored if the cxWordBreak flag is not set.

This flag disables the DT_EDITCONTROL flag in an underlying GDI DrawText function call.

cxDontClip

The DrawText procedure displays text without clipping. This flag slightly increases performance.

This flag corresponds to the DT_NOCLIP flag in an underlying GDI DrawText function call.

cxDontPrint

The DrawText procedure calculates the rectangle required to display the specified text. Text will not be drawn.

This flag corresponds to the DT_CALCRECT flag in an underlying GDI DrawText function call.

cxExpandTabs

Expands tab characters. The default number of characters per tab is eight.

This flag corresponds to the DT_EXPANDTABS flag in an underlying GDI DrawText function call.

cxShowEndEllipsis

The DrawText procedure crops the last portion of text that does not fit into the target rectangle and displays an ellipsis at the end of the visible text.

This flag corresponds to the DT_END_ELLIPSIS flag in an underlying GDI DrawText function call.

cxShowPrefix

Forces the DrawTexT procedure to parse prefix characters. If this flag is set, the procedure hides the ampersand character (&) in source text and underscores the following character. To display a single ampersand character in this mode, you need to insert two ampersands into source text (&&).

This flag disables the DT_NOPREFIX flag in an underlying GDI DrawText function call.

cxShowPathEllipsis

The DrawTexT procedure replaces a portion of text in the middle of the displayed string with an ellipsis if text does not fit into the target rectangle. If the displayed string contains backslash () characters, the DrawText procedure preserves as much text as possible after the last backslash.

This flag corresponds to the DT_PATH_ELLIPSIS flag in an underlying GDI DrawText function call.

cxSingleLine

Forces the DrawTexT procedure to display text in a single line only. Carriage return and line feed characters are ignored in this mode.

This flag corresponds to the DT_SINGLELINE flag in an underlying GDI DrawText function call.

cxWordBreak

The DrawTexT procedure breaks text into multiple lines between words if a word extends beyond the edge of the target rectangle. Carriage return and line feed characters create additional line breaks. A carriage return/line feed sequence also breaks the line. Use the cxDontBreakChars flag value to specify whether the last line of text is partially visible.

This flag corresponds to the DT_WORDBREAK flag in an underlying GDI DrawText function call.

See Also