UINT GetTextAlign(hdc) | |||||
HDC hdc; | /* device-context handle | */ |
The GetTextAlign function retrieves the status of the text alignment flags. The text alignment flags determine how the TextOut and ExtTextOut functions align a string of text in relation to the string's reference point, which is provided to TextOut or ExtTextOut.
hdc
Identifies the device context.
The return value specifies the status of the text alignment flags. The return value is a combination of one or more of the following values. The bounding rectangle is a rectangle bounding all the character cells and has the size returned by GetTextExtent.
Value | Meaning |
TA_BASELINE | The reference point will be on the baseline of the text. |
TA_BOTTOM | The reference point will be on the bottom edge of the bounding rectangle. |
TA_TOP | The reference point will be on the top edge of the bounding rectangle. |
TA_CENTER | The reference point will be aligned horizontally with the center of the bounding rectangle. |
TA_LEFT | The reference point will be on the left edge of the bounding rectangle. |
TA_RIGHT | The reference point will be 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. |
When the current font has a vertical default baseline, e.g. as with Kanji, then the following values will be used instead of TA_BASELINE and TA_CENTER.
Value | Meaning |
VTA_BASELINE | The reference point will be on the baseline of the text. |
VTA_CENTER | The reference point will be aligned vertically with the center of the bounding rectangle. |
If an error occurs, the value ERROR is returned.
The text alignment flags are not necessarily single bit flags and may be equal to zero.
The flags must be examined in groups of related flags, shown in the following list:
TA_LEFT, TA_RIGHT, and TA_CENTER.
TA_BOTTOM, TA_TOP, and TA_BASELINE.
TA_NOUPDATECP and TA_UPDATECP.
If the current font has a vertical default baseline, the related flags are instead:
TA_LEFT, TA_RIGHT, and VTA_BASELINE.
TA_BOTTOM, TA_TOP, and VTA_CENTER.
TA_NOUPDATECP and TA_UPDATECP.
To verify that a particular flag is set in the return value of this function, the application must perform the following steps:
1 | Apply the bitwise OR operator to the flag and its related flags. |
2 | Apply the bitwise AND operator to the result and the return value. |
3 | Test for the equality of this result and the flag. |
The following example shows a method for determining which horizontal alignment flag is set:
switch ((TA_LEFT | TA_RIGHT | TA_CENTER) & GetTextAlign(hdc))
{
case TA_LEFT:
.
.
.
case TA_RIGHT:
.
.
.
case TA_CENTER:
.
.
.
}
ExtTextOut, SetTextAlign, TextOut