Graphics::SetClip(HRGN,CombineMode) method (gdiplusgraphics.h)

The Graphics::SetClip method updates the clipping region of this Graphics object to a region that is the combination of itself and a Windows Graphics Device Interface (GDI) region.

Syntax

Status SetClip(
  [in] HRGN        hRgn,
  [in] CombineMode combineMode
);

Parameters

[in] hRgn

Type: HRGN

Handle to a GDI region to be combined with the clipping region of this Graphics object. This is provided for legacy code. New applications should pass a Region object as the first parameter.

[in] combineMode

Type: CombineMode

Optional. Element of the CombineMode enumeration that specifies how the GDI region is combined with the clipping region of this Graphics object. The default value is CombineModeReplace.

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

This method assumes that the GDI region specified by hRgn is already in device units, so it does not transform the coordinates of the GDI region.

Examples

The following example uses a GDI region to update the clipping region.

VOID Example_SetClip2(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a Region object, and get its handle.
   Region region(Rect(0, 0, 100, 100));
   HRGN hRegion = region.GetHRGN(&graphics);

   // Set the clipping region with hRegion.
   graphics.SetClip(hRegion);

   // Fill a rectangle to demonstrate the clipping region.
   graphics.FillRectangle(&SolidBrush(Color(255, 0, 0, 0)), 0, 0, 500, 500);
}

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

See also

Clipping

Clipping with a Region

CombineMode

GetClipBounds Methods

Graphics

Graphics::GetClip

Graphics::IsClipEmpty

Graphics::ResetClip

IntersectClip Methods

TranslateClip Methods