Home > Software engineering >  How to set up a GDI cutting area
How to set up a GDI cutting area

Time:10-06

Draw the background, I don't want to separate out an area map, how to do?

CodePudding user response:

 Graphics: : SetClip (hRgn, combineMode) 
The SetClip method updates The clipping region of this Graphics object to a region that is The combination translate and a GDI region.

The Status SetClip (
HRGN HRGN,
CombineMode CombineMode
);
The Parameters
HRgn
[in] 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.
CombineMode
[in] Optional. The 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.
The Return Values
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.

Few
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.

Example Code [c + +]
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 (the Rect (0, 0, 100, 100));
HRGN hRegion=region. GetHRGN (& amp; Graphics);

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

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

See the MSDN combineMode values
  • Related