Page 1 of 1

Draw on Canvas

Posted: Sun Feb 03, 2008 3:01 am
by 10546824
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?

Posted: Thu Feb 14, 2008 9:30 pm
by Tom
Hi medelo,

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

Thanks,
tom

Posted: Fri Feb 15, 2008 12:46 am
by 10546824
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

Posted: Tue Feb 19, 2008 5:28 pm
by Tom
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