SetTextAlign
This function sets the text-alignment value for the specified device context.
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_TOP The reference point is on the top 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_RIGHT The reference point is on the right edge of the bounding rectangle. TA_NOUPDATECP The current position is not updated after each text output call. 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
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.