Board index » delphi » Problems with drawing on Image.Canvas
l...@garnet.msen.com (Limno-Tech Inc.)
![]() Delphi Developer |
Mon, 09 Mar 1998 03:00:00 GMT
Problems with drawing on Image.Canvas
I am trying to copy a graph drawn by my Delphi program to the clipboard.
Since I can't figure out how to create a Windows metafile, I've been trying to draw the graph on the Canvas of an Image object so that I can copy it using Clipboard.Assign. Unfortunately, I've run into two problems: 1) When I maximize the form with the image, the graph is clipped 2) Lines draw funny - the diagonal lines drawn by the example code Suggestions? Tad Slawecki (t...@limno.com) ----- Example code starts here ----- procedure TForm1.FormPaint(Sender: TObject); { Form1 has an Image component named Image1 } var scrxr, scryr, scrxmin, scrymin: integer; begin { ----- Size Image1 to window ----- } Image1.SetBounds(1,1,ClientWidth - 1,ClientHeight -1 ); { ----- Create a solid pen ----- } NewPen := CreatePen(PS_SOLID,1,0); { ----- Determine plot size ----- } scrxr := ClientWidth - 10; scrxmin := 5; { ----- Clear Image1 ----- } Rectangle(Image1.Canvas.Handle,1,1,ClientWidth-1,ClientHeight-1); { ----- Draw box ----- } Rectangle(Image1.Canvas.Handle,scrxmin,scrymin, { ----- Draw diagonals ----- } MoveTo(Image1.Canvas.Handle,scrxmin,scrymin); MoveTo(Image1.Canvas.Handle,scrxmin+scrxr,scrymin); { ----- Draw additional line ----- } MoveTo(Image1.Canvas.Handle,scrxmin+1,scrymin); { ----- Delete pen ----- } SelectObject(Image1.Canvas.Handle,OldPen); end; procedure TForm1.FormResize(Sender: TObject); |