SetTextAlign Function

Declare Function SetTextAlign Lib "gdi32.dll" (ByVal hdc As Long, ByVal wFlags As Long) As Long

Platforms: Win 32s, Win 95/98, Win NT

SetTextAlign specifies how a device displays text relative to a given reference point. The reference point is the point used to identify where a line of text should be written. The function returns 1 if successful, or 0 if an error occured.

hdc
The device context of the device to set the reference point alignment of.
wFlags
Up to three of the following flags specifying where the text will be written in relation to a given reference point. Only one flag may be specified for horizontal alignment, vertical alignment, and current point updating.
TA_BASELINE = 24
The reference point will be on the baseline of the text.
TA_BOTTOM = 8
The reference point will be on the bottom edge of the bounding rectangle of the text.
TA_CENTER = 6
The reference point will be horizontally centered along the bounding rectangle of the text.
TA_LEFT = 0
The reference point will be on the left edge of the bounding rectangle of the text.
TA_NOUPDATECP = 0
Do not set the current point to the reference point.
TA_RIGHT = 2
The reference point will be on the right edge of the bounding rectangle of the text.
TA_RTLREADING = 256
Win 95/98 only:Display the text right-to-left (if the font is designed for right-to-left reading).
TA_TOP = 0
The reference point will be on the top edge of the bounding rectangle of the text.
TA_UPDATECP = 1
Set the current point to the reference point.

Example:

' Display the text "Hello, world!" on window Form1 at (100,50).
' Center the text horizontally at that point and have it appear below the point.
Dim retval As Long  ' return value

' Set the reference point to be centered horizontally and on the top edge of the text:
retval = SetTextAlign(Form1.hDC, TA_CENTER Or TA_TOP Or TA_NOUPDATECP)
' Display the text:
retval = TextOut(Form1.hDC, 100, 50, "Hello, world!", 13)

See Also: GetTextAlign, TextOut
Category: Fonts & Text

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/s/settextalign.html