다음을 통해 공유


SetTextAlign (Windows CE 5.0)

Send Feedback

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

WINGDIAPI UINT WINAPI SetTextAlign(HDChdc,UINTfmode);

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 Values

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

OS Versions: Windows CE .NET 4.0 and later.
Header: Windows.h.
Link Library: Coredll.lib.

See Also

ExtTextOut | GetTextAlign

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.