This function sets the text-alignment value for the specified device context.
WINGDIAPI UINT WINAPI SetTextAlign( HDC hdc, UINT fmode );
[in] Handle to the device context.
[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.
The reference point is on the base line of the text.
The reference point is on the bottom edge of the bounding rectangle.
The reference point is aligned horizontally with the center of the bounding rectangle.
The reference point is on the left edge of the bounding rectangle.
The current position is not updated after each text output call.
The reference point is on the right edge of the bounding rectangle.
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.
The reference point is on the top edge of the bounding rectangle.
The current position is updated after each text output call.
The previous text-alignment setting indicates success. GDI_ERROR indicates failure. To get extended error information, call GetLastError.
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)