Writes a character string at the specified location using the currently selected font.
virtual BOOL TextOut( int x, int y, LPCTSTR lpszString, int nCount ); BOOL TextOut( int x, int y, const CString& str ); |
Parameters
-
x
-
Specifies the logical x-coordinate of the starting point of the text.
-
y
-
Specifies the logical y-coordinate of the starting point of the text.
-
lpszString
-
Points to the character string to be drawn.
-
nCount
-
Specifies the number of bytes in the string.
-
str
-
A CString object that contains the characters to be drawn.
Return Value
Nonzero if the function is successful; otherwise 0.
Remarks
Character origins are at the upper-left corner of the character cell. By default, the current position is not used or updated by the function.
If an application needs to update the current position when it calls TextOut, the application can call the SetTextAlign member function with nFlags set to TA_UPDATECP. When this flag is set, Windows ignores the x and y parameters on subsequent calls to TextOut, using the current position instead.
Example
See the example for CDC::BeginPath.
See Also
Reference
CDC ClassHierarchy Chart
CDC::ExtTextOut
CDC::GetTextExtent
CDC::SetTextAlign
CDC::SetTextColor
CDC::TabbedTextOut
TextOut
Other Resources
CDC Members// Obtain the window's client rectangle
GetClientRect(hwnd, &r);
// THE FIX: by setting the background mode
// to transparent, the region is the text itself
// SetBkMode(hdc, TRANSPARENT);
// Bracket begin a path
BeginPath(hdc);
// Send some text out into the world
TCHAR text[ ] = "Defenestration can be hazardous";
TextOut(hdc,r.left,r.top,text, ARRAYSIZE(text));
// Bracket end a path
EndPath(hdc);
// Derive a region from that path
SelectClipPath(hdc, RGN_AND);
// This generates the same result as SelectClipPath()
// SelectClipRgn(hdc, PathToRegion(hdc));
// Fill the region with grayness
FillRect(hdc, &r, GetStockObject(GRAY_BRUSH));