Board index » delphi » Setting ClipRect?

Setting ClipRect?

Is it possible to -set- ClipRect? As stated in the help, it sets this to
an optimized value when calling the OnPaint handler. But I need to disable
this for my component because it needs to draw on the entire canvas every
time. How can I set ClipRect??

 

Re:Setting ClipRect?


To set clipping region of 'aComponent' to 'aRect' try the following -

    var clip: HRgn;

     // set the clipping region
     clip := CreateRectRgnIndirect(aRect);
     SelectClipRgn(aComponent.Canvas.Handle, clip);
     DeleteObject(clip);

     // do the drawing

     // reset the clipping region
     clip := CreateRectRgnIndirect(aComponent.ClientRect);
     SelectClipRgn(aComponent.Canvas.Handle, clip);
     DeleteObject(clip);

GTABSoft2 <gtabso...@aol.com> wrote in article
<19970104222400.RAA01...@ladder01.news.aol.com>...

Quote
> Is it possible to -set- ClipRect? As stated in the help, it sets this to
> an optimized value when calling the OnPaint handler. But I need to
disable
> this for my component because it needs to draw on the entire canvas every
> time. How can I set ClipRect??

Re:Setting ClipRect?


Quote
> How can I set ClipRect??

Invalidate the object, or call the invalidateRect API call for the entire
region that you want to invalidate.

Re:Setting ClipRect?


Steve Davidson <sdpi...@wolfenet.com> wrote in article =
<01bbfe88$a0f5eee0$b1832299@smd-p133>...

Quote
> > How can I set ClipRect??
>=20
> Invalidate the object, or call the invalidateRect API call for the =
entire
> region that you want to invalidate.
>=20

Hmmm.  I didn't see the original question, but I think this may be more =
like what we're after:

        var
           ClipRegion : HRGN ;

          :
          :

        try
          { Create a rectangular clip region bound by x1, y1 and x2, y2 }
          ClipRegion :=3D CreateRectRgn( x1, y1, x2, y2 ) ;
          SelectClipRgn( Canvas.Handle, ClipRegion ) ;
            :
          { Do canvas rendering here... }
            :
        finally
          { Make sure that clipping region is reset to NULL, }
          { and that the region object is deleted.                }
          SelectClipRgn( Canvas.Handle, 0 ) ;
          DeleteObject( ClipRegion ) ;
        end ;

Other Threads