Setting a DigitalPaint Clipping Region
Clipping is used by the toolkit to limit the output to a user-defined region. This can be done using the L_PntSetClipRgn function. To get the last clipping region set, call L_PntGetClipRgn. To offset a clipping region, call L_PntOffsetClipRgn.
L_INT OnPaintShape ( HWND hWnd )
{
pPAINTHANDLE pPaint ;
HDC hDC ;
HRGN hClipRgn ;
RECT rcShapeRect ;
/* Initiate the Paint toolkit */
if ( SUCCESS != L_PntInit ( &pPaint ) )
{
return FAILURE ;
}
/* Get device context to draw on */
hDC = GetDC ( hWnd ) ;
/*Set the rectangle coordinates with respect to the DC dimensions*/
SetRect ( &rcShapeRect, 10, 10, 110, 110 ) ;
/*Use the current shape properties to draw an ellipse to DC (hDC) */
L_PntDrawShapeEllipse ( pPaint, hDC, &rcShapeRect ) ;
hClipRgn = CreateRectRgn ( 120, 20, 200, 100 ) ;
/*Set painting clip region */
L_PntSetClipRgn ( pPaint, hClipRgn ) ;
/*Set the rectangle coordinates with respect to the DC dimensions*/
SetRect ( &rcShapeRect, 110, 10, 210, 110 ) ;
/*Use the current shape properties to draw an ellipse to DC (hDC) */
L_PntDrawShapeEllipse ( pPaint, hDC, &rcShapeRect ) ;
/*Delete the clip region */
DeleteObject ( ( HRGN ) hClipRgn ) ;
/*Release the device context */
ReleaseDC ( hWnd, hDC ) ;
/* Free the paint tools handle */
L_PntFree ( pPaint ) ;
return SUCCESS ;
}