CGpStringFormat.Clonemethod
Copies the contents of the existing **StringFormat** object into a new **StringFormat** object.
Syntax
FUNCTION Clone (BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
pStringFormat | Pointer to the StringFormat object where to copy the contents of the existing object. |
Description
Copies the contents of the existing StringFormat object into a new StringFormat object.
Example
' ======================================================================================== ' The following example creates a StringFormat object, clones it, and then uses the clone ' to draw a formatted string. ' ======================================================================================== SUB Example_Clone (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi
' // Create a red solid brush DIM solidBrush AS CGpSolidBrush = ARGB_RED ' // Create a font family from name DIM fontFamily AS CGpFontFamily = "Times New Roman" ' // Create a font from the font family DIM pFont AS CGpFont = CGpFont(@fontFamily, AfxGdipPointsToPixels(16, TRUE), FontStyleRegular, UnitPixel)
' // Create a string format object and set the alignment DIM stringFormat AS CGpStringFormat stringFormat.SetAlignment(StringAlignmentCenter)
' // Clone the StringFormat object DIM pStringFormat AS CGpStringFormat stringFormat.Clone(@pStringFormat) ' // You can also use: ' DIM pStringFormat AS CGpStringFormat = @stringFormat
' // Use the cloned StringFormat object in a call to DrawString DIM wszText AS WSTRING * 260 = "This text was formatted by a StringFormat object." graphics.DrawString(@wszText, LEN(wszText), @pFont, 30, 30, 200, 200, @pStringFormat, @solidBrush)
' // Draw the rectangle that encloses the text DIM pen AS CGpPen = ARGB_RED graphics.DrawRectangle(@pen, 30, 30, 200, 200)
END SUB ' ========================================================================================
Reference
- Include file
CGpStringFormat.inc - Defined in AfxNova/CGpStringFormat.inc:45
- Documented in Graphics/GdiPlus Classes/CGpStringFormat Class.md
- Topic: CGpStringFormat Class