Graphics::D rawString 方法根据字体和字符串的原点绘制字符串。
语法
Status DrawString(
  [in]      const WCHAR    *string,
  [in]      INT            length,
  [in]      const Font     *font,
  [in, ref] const PointF & origin,
  [in]      const Brush    *brush
);
参数
[in] string
类型: const WCHAR*
指向要绘制的宽字符字符串的指针。
[in] length
类型: INT
指定 字符串 数组中的字符数的整数。 如果字符串为 null 终止,则可以将 length 参数设置为 –1。
[in] font
类型: const Font*
指向 Font 对象的指针,该对象指定字体属性 (要使用的字体名称、大小和样式) 。
[in, ref] origin
类型: const PointF
对指定字符串起点的 PointF 对象的引用。
[in] brush
类型: const Brush*
指向用于填充字符串的 Brush 对象的指针。
返回值
类型: 状态
如果方法成功,则返回 Ok,这是 Status 枚举的元素。
如果 方法失败,它将返回 Status 枚举的其他元素之一。
注解
请注意,GDI+ 不支持没有 TrueType 轮廓的 PostScript 字体或 OpenType 字体。
使用 GDI+ API 时,不得允许应用程序从不受信任的源下载任意字体。 操作系统需要提升的权限,以确保所有已安装的字体都受信任。
示例
以下示例在指定的原点绘制一个字符串。
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);
}
要求
| 最低受支持的客户端 | Windows XP、Windows 2000 Professional [仅限桌面应用] | 
| 最低受支持的服务器 | Windows 2000 Server [仅限桌面应用] | 
| 目标平台 | Windows | 
| 标头 | gdiplusgraphics.h (包括 Gdiplus.h) | 
| Library | Gdiplus.lib | 
| DLL | Gdiplus.dll |