Board index » cppbuilder » Trouble with ClipRect on TCanvas and TMetafileCanvas

Trouble with ClipRect on TCanvas and TMetafileCanvas

I using a TMetafile canvas to draw a TChart onto using the
TChart->Draw(TCanvas*, TRect) method.  On top of the resulting canvas, I wish to
draw numerous lines, text, boxes, etc., using the same canvas I passed in to the
Draw method.  The problem which arises is when I want to draw beyond the
ClipRect of the canvas.  ClipRect is read-only, so I cannot change it.  Now, I
know the necessary dimensions beforehand, but I do not know how the ClipRect is
set.  Specifying the dimensions of the TMetafile which is used to create the
TMetafileCanvas does not have any effect.

How can I set the ClipRect for a TCanvas and TMetafileCanvas?

--

Joshua D. Bush -0-0-0-0-0-0-0-0-0-0-0-0-0-0-0- The Scarlet Pumpkin

 

Re:Trouble with ClipRect on TCanvas and TMetafileCanvas


You must ust the winAPI to adjust the cliprect as the cliprect property is read only
and just reads the currently set clipping region. The following code snippits
redefine the cliprect and the resets it back to the original:

   HRGN MyRgn;

   MyRgn = ::CreateRectRgn(100,100,200,200);
   ::SelectClipRgn(Image8->Canvas->Handle,MyRgn);
   Ellipse(Image8->Canvas->Handle,90,90,210,210);
   Image8->Invalidate();
   ::SelectClipRgn(Image8->Canvas->Handle,NULL);
   ::DeleteObject(MyRgn);

-jc

Quote
Joshua D. Bush wrote:
> I using a TMetafile canvas to draw a TChart onto using the
> TChart->Draw(TCanvas*, TRect) method.  On top of the resulting canvas, I wish to
> draw numerous lines, text, boxes, etc., using the same canvas I passed in to the
> Draw method.  The problem which arises is when I want to draw beyond the
> ClipRect of the canvas.  ClipRect is read-only, so I cannot change it.  Now, I
> know the necessary dimensions beforehand, but I do not know how the ClipRect is
> set.  Specifying the dimensions of the TMetafile which is used to create the
> TMetafileCanvas does not have any effect.

> How can I set the ClipRect for a TCanvas and TMetafileCanvas?

> --

> Joshua D. Bush -0-0-0-0-0-0-0-0-0-0-0-0-0-0-0- The Scarlet Pumpkin

Other Threads