Recent

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

Michael Collier

  • Sr. Member
  • ****
  • Posts: 257
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: 914
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 x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (2004)

Michael Collier

  • Sr. Member
  • ****
  • Posts: 257
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?

 

TinyPortal © 2005-2018