绘制背景,我想独立出一块区域不绘制,如何做?

解决方案 »

  1.   

    Graphics::SetClip(hRgn, combineMode)
    The SetClip method updates the clipping region of this Graphics object to a region that is the combination of itself and a GDI region.Status SetClip(
      HRGN hRgn,
      CombineMode combineMode
    );
    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. 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 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.Res
    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(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);
    }combineMode取值见MSDN