Draw on Canvas

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
mendelo
Newbie
Newbie
Posts: 11
Joined: Wed Sep 26, 2007 12:00 am

Draw on Canvas

Post by mendelo » Sun Feb 03, 2008 3:01 am

If on the mouse up event I use

Tree1.Canvas.Draw(X,Y,Bitmap)

this works fine until I do anything else, such as turn on or off the grid, go to add a TreeNodeShape, etc. then the image disappears. How can I save the canvas?

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Thu Feb 14, 2008 9:30 pm

Hi medelo,

Can you please tell me a little bit more what you would like to achieve?

Thanks,
tom

mendelo
Newbie
Newbie
Posts: 11
Joined: Wed Sep 26, 2007 12:00 am

Post by mendelo » Fri Feb 15, 2008 12:46 am

Hi Tom

Thanks for the reply

I am using the TTree components for users to map out farms and overlay building, pens and other features, using TTreeNodeShapes. This is all working very well. The background is an overhead image of the farm from Google Earth that is used as a template. Some features on the farm I do not need to save as a TreeNodeShape as they have no attached objects.Streams and paths are an example. In this case I am allowing them to draw directly on the canvas . Again this works well until such time as the canvas is refreshed, in which case the drawing disappears. I am guessing I need to save the canvas before any additional processing. Hope this helps

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Tue Feb 19, 2008 5:28 pm

Hi mendelo,

Please use the OnAfterDraw or the OnBeforeDraw event to redraw your users objects: e.g.

Code: Select all

procedure TForm2.Tree1BeforeDraw(Sender: TObject);
begin
  Tree1.Canvas.DoRectangle(Rect(0,0,50,50));
end;

procedure TForm2.Tree1AfterDraw(Sender: TObject);
begin
  Tree1.Canvas.DoRectangle(Rect(50,50,100,100));
end;
Regards,
tom

Post Reply