GraphicsPath::AddString(constWCHAR*,INT,constFontFamily*,INT,REAL,constPointF&,constStringFormat*) 方法 (gdipluspath.h)
GraphicsPath::AddString 方法會將字串的外框新增至此路徑。
語法
Status AddString(
const WCHAR *string,
INT length,
const FontFamily *family,
INT style,
REAL emSize,
const PointF & origin,
const StringFormat *format
);
參數
string
寬字元字串的指標。
length
整數,指定要顯示的字元數。 如果字串參數指向 NULL終止字串,則可以將此參數設定為 –1。
family
FontFamily 物件的指標,指定字串的字型系列。
style
指定字樣樣式的整數。
這個值必須是 FontStyle 列舉的元素,或是套用至其中兩個或多個元素的位 OR 結果。
例如,FontStyleBold | FontStyleUnderline | FontStyleStrikeout
將樣式設定為三種樣式的組合。
emSize
實數,指定字串字元 em 大小,以世界單位為單位。
origin
PointF 對象的參考,指定字串的位置,以世界單位為單位。
format
StringFormat 物件的指標,指定字串的配置資訊(對齊、修剪、製表位等)。
傳回值
類型:狀態
如果方法成功,它會傳回Ok,這是 Status 列舉的元素。
如果方法失敗,它會傳回 Status 列舉的其他元素之一。
言論
請注意,GDI+ 不支援 PostScript 字型或 OpenType 字型,這些字型沒有 TrueType 外框。
例子
下列範例會建立 GraphicsPath 對象路徑、將 NULL 終止的字串新增至 path,然後繪製路徑。
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,
PointF(50.0f, 50.0f),
NULL);
Pen pen(Color(255, 255, 0, 0));
graphics.DrawPath(&pen, &path);
}
要求
要求 | 價值 |
---|---|
標頭 | gdipluspath.h |
另請參閱
使用區域 進行裁剪