StringFormat.SetTrimming method
Applies to: desktop apps only
The StringFormat::SetTrimming method sets the trimming style for this StringFormat object. The trimming style determines how to trim a string so that it fits into the layout rectangle.
Syntax
Status SetTrimming( [in] StringTrimming trimming );
Parameters
- trimming [in]
-
Type: StringTrimming
Element of the StringTrimming enumeration that specifies the style of trimming to be performed on the string.
Return value
Type:
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.
Examples
The following example creates a StringFormat object, sets the trimming style, and uses the StringFormat object to draw a string. The code also draws the string's layout rectangle.
VOID Example_SetTrimming(HDC hdc)
{
Graphics graphics(hdc);
SolidBrush solidBrush(Color(255, 255, 0, 0));
FontFamily fontFamily(L"Times New Roman");
Font font(&fontFamily, 24, FontStyleRegular, UnitPixel);
StringFormat stringFormat;
stringFormat.SetTrimming(StringTrimmingEllipsisWord);
graphics.DrawString(
L"One two three four five six seven eight nine ten",
47, // string length
&font,
RectF(30, 30, 160, 60),
&stringFormat,
&solidBrush);
// Draw the rectangle that encloses the text.
Pen pen(Color(255, 255, 0, 0));
graphics.DrawRectangle(&pen, 30, 30, 160, 60);
}
Requirements
|
Minimum supported client | Windows XP, Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Product | GDI+ 1.0 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/6/2012