Share via


SetTextAlign

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function sets the text-alignment value for the specified device context.

Syntax

WINGDIAPI UINT WINAPI SetTextAlign(
  HDC hdc,
  UINT fmode
);

Parameters

  • hdc
    [in] Handle to the device context.
  • fmode
    [in] Unsigned integer that specifies the text alignment by using a mask of the values. The following table shows the possible values. You can combine only one of the values that affects horizontal and with only one of the values that affects vertical alignment. In addition, you can combine the horizontal and vertical values with only one of the two flags that alter the current position. The default values are TA_LEFT, TA_TOP, and TA_NOUPDATECP.

    Value Description

    TA_BASELINE

    The reference point is on the base line of the text.

    TA_BOTTOM

    The reference point is on the bottom edge of the bounding rectangle.

    TA_CENTER

    The reference point is aligned horizontally with the center of the bounding rectangle.

    TA_LEFT

    The reference point is on the left edge of the bounding rectangle.

    TA_NOUPDATECP

    The current position is not updated after each text output call.

    TA_RIGHT

    The reference point is on the right edge of the bounding rectangle.

    TA_RTLREADING

    The text is laid out in right-to-left reading order, as opposed to the default left-to-right order. This applies only when the font selected into the device context is either Hebrew or Arabic.

    TA_TOP

    The reference point is on the top edge of the bounding rectangle.

    TA_UPDATECP

    The current position is updated after each text output call.

Return Value

The previous text-alignment setting indicates success. GDI_ERROR indicates failure. To get extended error information, call GetLastError.

Remarks

The ExtTextOut function uses the text-alignment value to position a string of text on a display or other device. The values specify the relationship between a reference point and a rectangle that bounds the text. The reference point is either the current position or a point that you pass to ExtTextOut. The rectangle that bounds the text is formed by the character cells in the text string.

The following code example shows the two best methods for specifying left-aligned text.

SetTextAlign (hdc, GetTextAlign(hdc) & (~TA_CENTER))
SetTextAlign (hdc, TA_LEFT | <other flags>)

The following code example shows a method for specifying left-aligned text that is not recommended because this method loses any vertical settings that you previously specified.

SetTextAlign (hdc, TA_LEFT)

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also

Reference

ExtTextOut
GetTextAlign