Page 1 of 1

How to cast TCanvas3D to TCanvas and vice a versa

Posted: Tue Nov 21, 2006 10:29 am
by 9343617
I need to pass the canvas of the VCL as parameter to some methods who in turn do some drawing operations on the canvas. For this I need to do class casting from TCavas3D to TCanvas and vice a versa. But it seems that since both of these are not compatible so compiler complains and does not even compiles the code.

Can some one please help some alternative.

Thanks in advance

Posted: Tue Nov 21, 2006 10:41 am
by narcis
Hi Sunil,

To cast from a TCanvas3D to a TCanvas you can use this:

Code: Select all

  DBChart1.Canvas.ReferenceCanvas
For the inverse operation this:

Code: Select all

var MyCanvas: TCanvas;
begin
  MyCanvas:=TCanvas.Create;
  (MyCanvas as TCanvas3D).Rectangle(...);
end;