GetTextAlign

Syntax

WORD GetTextAlign(hDC)

This 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 starting point.

Parameter Type/Description  

hDC HDC Identifies the device context.  

Return Value

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:

Value Meaning  

TA_BASELINE Specifies alignment of the x-axis and the baseline of the chosen font within the bounding rectangle.  
TA_BOTTOM Specifies alignment of the x-axis and the bottom of the bounding rectangle.  
TA_CENTER Specifies alignment of the y-axis and the center of the bounding rectangle.  
TA_LEFT Specifies alignment of the y-axis and the left side of the bounding rectangle.  
TA_NOUPDATECP Specifies that the current position is not updated.  
TA_RIGHT Specifies alignment of the y-axis and the right side of the bounding rectangle.  
TA_TOP Specifies alignment of the x-axis and the top of the bounding rectangle.  
TA_UPDATECP Specifies that the current position is updated.  

Comments

The text-alignment flags are not necessarily single-bit flags and may be equal to zero. To verify that a particular flag is set in the return value of this function, build an application that will perform the following steps:

1.Apply the bitwise OR operator to the flag and its related flags.

The following list shows the groups of related flags:

TA_LEFT, TA_CENTER, and TA_RIGHT

TA_BASELINE, TA_BOTTOM, and TA_TOP

TA_NOUPDATECP and TA_UPDATECP

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

.

.

.

}