Help Center

CGpGraphicsPath.GetBoundsmethod

Gets a bounding rectangle for this path.

GraphicsmethodCGpPath.incdocumented

Syntax

FUNCTION GetBounds (BYVAL bounds AS GpRectF PTR, BYVAL pMatrix AS CGpMatrix PTR, BYVAL pPen AS CGpPen PTR) AS GpStatus
FUNCTION GetBounds (BYVAL bounds AS GpRect PTR, BYVAL pMatrix AS CGpMatrix PTR, BYVAL pPen AS CGpPen PTR) AS GpStatus

Parameters

NameDescription
boundsPointer to a GpRectF or GpRect structures that receives the bounding rectangle.
pMatrixOptional. Pointer to a Matrix object that specifies a transformation to be applied to this path before the bounding rectangle is calculated. This path is not permanently transformed; the transformation is used only during the process of calculating the bounding rectangle. The default value is NULL.
pPenOptional. Pointer to a Pen object that influences the size of the bounding rectangle. The bounding rectangle received in bounds will be large enough to enclose this path when the path is drawn with the pen specified by this parameter. This ensures that the path is enclosed by the bounding rectangle even if the path is drawn with a wide pen. The default value is NULL.

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

Gets a bounding rectangle for this path.

Example

' ======================================================================================== ' The following example creates a path that has one curve and one ellipse. The code draws ' the path with a thick yellow pen and a thin black pen. The GraphicsPath.GetBounds method ' receives the address of the thick yellow pen and calculates a bounding rectangle for the ' path. Then the code draws the bounding rectangle. ' ======================================================================================== SUB Example_GetBounds (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

DIM blackPen AS CGpPen = CGpPen(ARGB_BLACK, 1) DIM yellowPen AS CGpPen = CGpPen(ARGB_YELLOW, 10) DIM redPen AS CGpPen = CGpPen(ARGB_RED, 1)

DIM pts(0 TO 3) AS GpPoint = {(120, 120), (200, 130), (150, 200), (130, 180)}

' // Create a path that has one curve and one ellipse. DIM path AS CGpGraphicsPath path.AddClosedCurve(@pts(0), 4) path.AddEllipse(120, 220, 100, 40)

' // Draw the path with a thick yellow pen and a thin black pen. graphics.DrawPath(@yellowPen, @path) graphics.DrawPath(@blackPen, @path)

' // Get the path's bounding rectangle. DIM rc AS GpRect path.GetBounds(@rc, NULL, @yellowPen) graphics.DrawRectangle(@redPen, @rc)

END SUB ' ========================================================================================

Reference

  • Include file CGpPath.inc
  • Defined in AfxNova/CGpPath.inc:491
  • Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
  • Topic: CGpGraphics Class