GdipSetStringFormatFlagsfunction
Sets the format flags for a **StringFormat** object. The format flags determine most of the characteristics of a **StringFormat** object.
Syntax
FUNCTION GdipSetStringFormatFlags (BYVAL format AS GpStringFormat PTR, BYVAL flags AS INT_) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
format | [in] Pointer to the StringFormat object. | |
flags | [in] Thirty-two bit value that specifies the format flags that control most of the characteristics of the StringFormat object. The flags are set by applying a bitwise OR to elements of the StringFormatFlags. |
Description
Sets the format flags for a StringFormat object. The format flags determine most of the characteristics of a StringFormat object.
Example
' ======================================================================================== ' The following example creates a StringFormat object, sets the format flags, and draws the ' formatted string. The code also draws the string's layout rectangle. ' ======================================================================================== SUB Example_SetStringFormatFlags (BYVAL hdc AS HDC)
DIM hStatus AS LONG
' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)
' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)
' // Create the font DIM fontFamily AS GpFontFamily PTR hStatus = GdipCreateFontFamilyFromName("Times New Roman", NULL, @fontFamily) DIm font AS GpFont PTR IF hStatus = StatusOk THEN
hStatus = GdipCreateFont(fontFamily, AfxGdipPointsToPixels(18, TRUE), FontStyleRegular, UnitPixel, @font)
GdipDeleteFontFamily(fontFamily)
END IF
' // Create a StringFormat object, and set its format flags. DIM format AS GpStringFormat PTR hStatus = GdipCreateStringFormat(0, LANG_NEUTRAL, @format) hStatus = GdipSetStringFormatFlags(format, StringFormatFlagsDirectionVertical OR StringFormatFlagsNoFitBlackBox)
' // Create a solid brush DIM solidBrush AS GpSolidFill PTR hStatus = GdipCreateSolidFill(ARGB_RED, @solidBrush)
' // Use the StringFormat object in a call to DrawString. DIM wszText AS WSTRING * 64 = "This text is vertical because of a format flag." DIM rcf AS GpRectF = (30, 30, 150, 200) hStatus = GdipDrawString(graphics, wszText, LEN(wszText), font, @rcf, format, solidBrush)
' // Draw the rectangle that encloses the text. DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_RED, 1, UnitPixel, @pen) hStatus = GdipScalePenTransform(pen, rxRatio, ryRatio, MatrixOrderPrepend) hStatus = GdipDrawRectangle(graphics, pen, rcf.x, rcf.y, rcf.width, rcf.height)
' // Cleanup IF font THEN GdipDeleteFont(font) IF solidBrush THEN GdipDeleteBrush(solidBrush) IF pen THEN GdipDeletePen(pen) IF format THEN GdipDeleteStringFormat(format) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2398
- Documented in Graphics/GdiPlus Flat Api/GdiPlusStringFormat.md
- Topic: GdiPlusStringFormat