GraphicsPath::AddString (constWCHAR*,INT,constFontFamily*,INT,REAL,constPoint&,constStringFormat*) 方法 (gdipluspath.h)

GraphicsPath::AddString 方法會將字串的外框新增至此路徑。

語法

Status AddString(
  [in]      const WCHAR        *string,
  [in]      INT                length,
  [in]      const FontFamily   *family,
  [in]      INT                style,
  [in]      REAL               emSize,
  [in, ref] const Point &      origin,
  [in]      const StringFormat *format
);

參數

[in] string

類型: const WCHAR*

寬字元字串的指標。

[in] length

類型: INT

整數,指定要顯示的字元數。 如果 字串 參數指向 NULL終止的字串,這個參數可以設定為 –1。

[in] family

類型: const FontFamily*

FontFamily 物件的指標,指定字串的字型系列。

[in] style

類型: INT

指定字樣樣式的整數。 這個值必須是 FontStyle 列舉的元素,或是套用至其中兩個或多個元素的位 OR 結果。 例如, FontStyleBold | FontStyleUnderline | FontStyleStrikeout 將樣式設定為三種樣式的組合。

[in] emSize

類型: REAL

實際數位,指定字串字元的em大小,以世界單位為單位。

[in, ref] origin

類型: const Point

Point 對象的參考,指定以世界單位表示字串的位置。

[in] format

類型: const StringFormat*

StringFormat 物件的指標,指定 (對齊、修剪、製表位等配置資訊,以及字串的類似) 。

傳回值

類型: 狀態

如果方法成功,它會傳回Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。

備註

請注意,GDI+ 不支援 PostScript 字型或沒有 TrueType 外框的 OpenType 字型。

範例

下列範例會建立 GraphicsPath 物件 路徑、將 NULL 終止的字串新增至 路徑,然後繪製 路徑

VOID Example_AddString(HDC hdc)
{
   Graphics graphics(hdc);
   FontFamily fontFamily(L"Times New Roman");
   GraphicsPath path;

   path.AddString(
      L"Hello World", 
      -1,                 // NULL-terminated string
      &fontFamily, 
      FontStyleRegular, 
      48, 
      Point(50, 50),
      NULL);

   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawPath(&pen, &path);
}

規格需求

   
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 gdipluspath.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

AddString 方法

使用區域裁剪

建構和繪製路徑

建立路徑漸層

字型

FontFamily

FontStyle

GraphicsPath

StringFormat

使用文字和字型