TextOut Function

Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long

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

TextOut displays a line of text on a device. The relation of the text to the (x,y) pair passed to the function can be set using SetTextAlign. The text will be displayed using the device's currently selected font and text drawing color. The function returns 1 if successful, or 0 if an error occured.

hdc
The device context of the device to display the line of text on.
x
The x coordinate of the reference point to display the text at.
y
The y coordinate of the reference point to display the text at.
lpString
The string to display on the device.
nCount
The size in characters of lpString.

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, SetTextAlign
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/t/textout.html