Recent

Author Topic: Is it possible to get copyrect without a visual instance of tsynedit?  (Read 2080 times)

Michael Collier

  • Full Member
  • ***
  • Posts: 249
I'd like to copy the visual view of a TSynEdit onto a TImage canvas.

I have used copyrect to copy the canvas OK, but I'd like to try this without an instance of the TSynEdit being visible.

Is there any way I can do this already? Maybe low level calls or components that I don't know about?

Pascal

  • Hero Member
  • *****
  • Posts: 831
You can use PaintTo:

Code: Pascal  [Select]
  1.       lEdit := TSynEdit.Create(Panel2);
  2.       try
  3.         lEdit.Parent := Panel2;
  4.         lEdit.Lines.LoadFromFile('C:\freepascal\fpc\trunk\packages\rtl-generics\src\generics.collections.pas');
  5.         lEdit.PaintTo(Image1.Canvas.Handle, 0, 0);
  6.       finally
  7.         lEdit.Free;
  8.       end;
  9.  

But you have to set the parent of the TSynEdit to an invisible Control.
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

Michael Collier

  • Full Member
  • ***
  • Posts: 249
Thanks for the heads up on PaintTo, it works OK for me when the parent panel is visible, but if I hide either the parent panel (panel2) or the synedit (LEdit) the result is a black canvas in the image. Is there any other value I need to set please?