Graphics::DrawString(constWCHAR*,INT,constFont*,constPointF&,constBrush*) method (gdiplusgraphics.h)
The Graphics::DrawString method draws a string based on a font and an origin for the string.
Syntax
Status DrawString(
[in] const WCHAR *string,
[in] INT length,
[in] const Font *font,
[in, ref] const PointF & origin,
[in] const Brush *brush
);
Parameters
[in] string
Type: const WCHAR*
Pointer to a wide-character string to be drawn.
[in] length
Type: INT
Integer that specifies the number of characters in the string array. The length parameter can be set to –1 if the string is null terminated.
[in] font
Type: const Font*
Pointer to a Font object that specifies the font attributes (the family name, the size, and the style of the font) to use.
[in, ref] origin
Type: const PointF
Reference to a PointF object that specifies the starting point for the string.
[in] brush
Type: const Brush*
Pointer to a Brush object that is used to fill the string.
Return value
Type: Status
If the method succeeds, it returns Ok, which is an element of the Status enumeration.
If the method fails, it returns one of the other elements of the Status enumeration.
Remarks
Note that GDI+ does not support PostScript fonts or OpenType fonts which do not have TrueType outlines.
When you use the GDI+ API, you must not allow your application to download arbitrary fonts from untrusted sources. The operating system requires elevated privileges to assure that all installed fonts are trusted.
Examples
The following example draws a string at the specified origin.
VOID Example_DrawString2(HDC hdc)
{
Graphics graphics(hdc);
// Create a string.
WCHAR string[] = L"Sample Text";
// Initialize arguments.
Font myFont(L"Arial", 16);
PointF origin(0.0f, 0.0f);
SolidBrush blackBrush(Color(255, 0, 0, 0));
// Draw string.
graphics.DrawString(
string,
11,
&myFont,
origin,
&blackBrush);
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP, Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | gdiplusgraphics.h (include Gdiplus.h) |
Library | Gdiplus.lib |
DLL | Gdiplus.dll |