CGpGraphics.DrawStringmethod
Draws a string based on a font and an origin for the string.
Syntax
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpRectF PTR, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL nWidth AS SINGLE, BYVAL nHeight AS SINGLE, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpRect PTR, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS INT_, BYVAL y AS INT_, BYVAL nWidth AS INT_, BYVAL nHeight AS INT_, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpPointF PTR, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpPoint PTR, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS INT_, BYVAL y AS INT_, BYVAL pBrush AS CGpBrush PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpRectF PTR, BYVAL pBrush AS CGpBrush PTR; BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL nWidth AS SINGLE, BYVAL nHeight AS SINGLE, BYVAL pBrush AS CGpBrush PTR, BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpRect PTR, BYVAL pBrush AS CGpBrush PTR; BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS INT_, BYVAL y AS INT_, BYVAL nWidth AS INT_, BYVAL nHeight AS INT_, BYVAL pBrush AS CGpBrush PTR, BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpPointF PTR, BYVAL pBrush AS CGpBrush PTR; BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL pBrush AS CGpBrush PTR, BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL rc AS GpPoint PTR, BYVAL pBrush AS CGpBrush PTR; BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
FUNCTION DrawString (BYVAL pwszString AS WSTRING PTR, BYVAL length AS INT_, BYVAL pFont AS CGpFont PTR, BYVAL x AS INT_, BYVAL y AS INT_, BYVAL pBrush AS CGpBrush PTR, BYVAL pStringFormat AS CGpStringFormat PTR) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
pwszString | Pointer to a wide-character string to be drawn. | |
pFont | Pointer to a Font object that specifies the font attributes (the family name, the size, and the style of the font) to use. | |
x | The x-coordinate of the upper-left corner of the destination position at which to draw the string. | |
y | The y-coordinate of the upper-left corner of the destination position at which to draw the string. | |
pStringFormat | Pointer to a StringFormat object that specifies text layout information and display manipulations to be applied to the string. | |
pBrush | Pointer to a Brush object that is used to fill the string. |
Return value
If the function succeeds, it returns StatusOk, which is an element of the GpStatus enumeration.
If the function fails, it returns one of the other elements of the GpStatus enumeration.
Description
Draws a string based on a font and an origin for the string.
Example
' ======================================================================================== ' The following example creates a Font object from a family name and uses it to draw text. ' ======================================================================================== SUB Example_DrawString (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 font object DIM font AS CGpFont = CGpFont("Arial", AfxGdipPointsToPixels(16, TRUE), FontStyleRegular, UnitPoint) ' // Create solid brush DIM blackBrush AS CGpSolidBrush = ARGB_BLACK ' // Define layout rectangle DIM layoutRect AS GpRectF = (30, 30, 0, 0) ' // Define text to draw DIM wszText AS WSTRING * 64 = "Sample text" ' // Draw the string graphics.DrawString(wszText, LEN(wszText), @font, @layoutRect, @blackBrush)
END SUB ' ========================================================================================
Reference
- Include file
CGpGraphics.inc - Defined in AfxNova/CGpGraphics.inc:849
- Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
- Topic: CGpGraphics Class