Graphics::GetClipBounds(Rect*) method (gdiplusgraphics.h)
The Graphics::GetClipBounds method gets a rectangle that encloses the clipping region of this Graphics object.
Syntax
Status GetClipBounds(
[out] Rect *rect
);
Parameters
[out] rect
Type: Rect*
Pointer to a Rect object that receives the rectangle that encloses the clipping region.
Return value
Type: Status
If the method succeeds, it returns Ok, which is an element of the Status enumeration.
If the method fails, it returns one of the other elements of the Status enumeration.
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, Graphics::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.
Examples
The following example sets a clipping region, gets the rectangle that encloses the clipping region, and then fills the rectangle.
VOID Example_GetClipBounds(HDC hdc)
{
Graphics graphics(hdc);
Region myRegion(Rect(25, 25, 100, 50));
Rect rect(40, 60, 100, 50);
Region gRegion;
Rect enclosingRect;
SolidBrush blueBrush(Color(100, 0, 0, 255));
Pen greenPen(Color(255, 0, 255, 0), 1.5f);
// Modify the region by using a rectangle.
myRegion.Union(rect);
// Set the clipping region of the graphics object.
graphics.SetClip(&myRegion);
// Now, get the clipping region, and fill it.
graphics.GetClip(&gRegion);
graphics.FillRegion(&blueBrush, &gRegion);
// Get a rectangle that encloses the clipping region, and draw the enclosing
// rectangle.
graphics.GetClipBounds(&enclosingRect);
graphics.ResetClip();
graphics.DrawRectangle(&greenPen, enclosingRect);}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP, Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | gdiplusgraphics.h (include Gdiplus.h) |
Library | Gdiplus.lib |
DLL | Gdiplus.dll |