Board index » delphi » TCanvas.ClipRect Doc Error

TCanvas.ClipRect Doc Error

There is an inconsistency in the TCanvas.ClipRect documentation (see
below).  In it, it suggests that one can set the TCanvas.ClipRect to
control drawing, yet ClipRect is a read only property.

So... how does ClipRect get set?  If I have a paintbox that is 300 x
300 and I Draw a 16 x 16 bitmap onto the paintbox canvas, is the
ClipRect set to only the draw area or is it set to the paintbox
dimensions?

If I _could_ set the clip rect, would it reduce flicker in non double
buffered OnPaints?

 

Re:TCanvas.ClipRect Doc Error


You set it by invalidating (or validating) rectangles or regions.

TCanvas.ClipRect is just a wrapper around the Win32 GetClipBox() routine,
which just gets the rectangle that contains the invalidated region.

        int GetClipBox(HDC hdc, LPRECT lprc);

"Sue D. Nom" <su...@courthouse.com> wrote in message
news:3C8D6E5D.69A7C092@courthouse.com...

Quote
> There is an inconsistency in the TCanvas.ClipRect documentation (see
> below).  In it, it suggests that one can set the TCanvas.ClipRect to
> control drawing, yet ClipRect is a read only property.

> So... how does ClipRect get set?  If I have a paintbox that is 300 x
> 300 and I Draw a 16 x 16 bitmap onto the paintbox canvas, is the
> ClipRect set to only the draw area or is it set to the paintbox
> dimensions?

> If I _could_ set the clip rect, would it reduce flicker in non double
> buffered OnPaints?

Re:TCanvas.ClipRect Doc Error


That is what I want to know how to do.  I am drawing an area that is 50 x 50
on a 400 x 500 scroll box client area... the paintbox cliprect is set to the
full scroll box client area.  If I draw just a small part, must the whole
image inside the scroll box client area be invalidated?
Quote
Roy Green wrote:
> You set it by invalidating (or validating) rectangles or regions.

> TCanvas.ClipRect is just a wrapper around the Win32 GetClipBox() routine,
> which just gets the rectangle that contains the invalidated region.

>         int GetClipBox(HDC hdc, LPRECT lprc);

> "Sue D. Nom" <su...@courthouse.com> wrote in message
> news:3C8D6E5D.69A7C092@courthouse.com...
> > There is an inconsistency in the TCanvas.ClipRect documentation (see
> > below).  In it, it suggests that one can set the TCanvas.ClipRect to
> > control drawing, yet ClipRect is a read only property.

> > So... how does ClipRect get set?  If I have a paintbox that is 300 x
> > 300 and I Draw a 16 x 16 bitmap onto the paintbox canvas, is the
> > ClipRect set to only the draw area or is it set to the paintbox
> > dimensions?

> > If I _could_ set the clip rect, would it reduce flicker in non double
> > buffered OnPaints?

Re:TCanvas.ClipRect Doc Error


Sue,

How about something like this

var
Rgn : HRGN;

begin
  try
    Rgn := CreateRectRgn(x1, y1, x2, y2);
    SelectClipRgn(MyPaintBox.Canvas.Handle, Rgn);
    // Do your stuff here
  finally
    SelectClipRgn(MyPaintBox.Canvas.Handle, 0);
    DeleteObject(Rgn);
  end;
end;

Regards

Stan

Re:TCanvas.ClipRect Doc Error


No, but you'll have to use the Win32 API to do it.

    InvalidateRect(handle, @rect, not (csOpaque in ControlStyle))

"Sue D. Nom" <su...@courthouse.com> wrote in message
news:3C8E39E9.B2572BAD@courthouse.com...

Quote
> That is what I want to know how to do.  I am drawing an area that is 50 x
50
> on a 400 x 500 scroll box client area... the paintbox cliprect is set to
the
> full scroll box client area.  If I draw just a small part, must the whole
> image inside the scroll box client area be invalidated?

Other Threads