Help Center

CGpGraphics.GetClipBoundsmethod

Gets a rectangle that encloses the clipping region of this **Graphics** object.

GraphicsmethodCGpGraphics.incdocumented

Syntax

FUNCTION GetClipBounds (BYVAL rc AS GpRectF PTR) AS GpStatus
FUNCTION GetClipBounds (BYVAL rc AS GpRect PTR) AS GpStatus

Parameters

NameDescription
rcPointer to a GpRectF or GpRect object that receives the rectangle that encloses the clipping region.

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 rectangle that encloses the clipping region of this Graphics object.

Remarks

The world transformation is applied to the clipping region and then the enclosing rectangle is calculated.

If you do not explicitly set the clipping region of a Graphics object, its clipping region is infinite. When the clipping region is infinite, GetClipBounds returns a large rectangle. The X and Y data members of that rectangle are large negative numbers, and the Width and Height data members are large positive numbers.

Example

' ======================================================================================== ' The following example sets a clipping region, gets the rectangle that encloses the ' clipping region, and then fills the rectangle. ' ======================================================================================== SUB Example_GetClipBounds (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 region using a rectangle DIM myRegion AS CGpRegion = CGpRegion(25, 25, 100, 50)

' // Modify the region by using a rectangle DIM rcf AS GpRectF = (40, 50, 100, 50) myRegion.Union_(@rcf)

' // Set the clipping region of the graphics object graphics.SetClip(@myRegion)

' // Now, get the clipping region, and fill it DIM gRegion AS CGpRegion graphics.GetClip(@gRegion) DIM blueBrush AS CGpSolidBrush = ARGB_BLUE graphics.FillRegion(@blueBrush, @gRegion)

' // Get a rectangle that encloses the clipping region, and draw the enclosing rectangle DIM enclosingRect AS GpRectF graphics.GetClipBounds(@enclosingRect) graphics.ResetClip DIM greenPen AS CGpPen = CGpPen(ARGB_LIGHTGREEN, 1.5) graphics.DrawRectangle(@greenPen, @enclosingRect)

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

Reference

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