"Canvas does not allow drawing" document with SRVControls

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
mcperes
Posts: 6
Joined: Thu Jan 04, 2018 10:38 pm

"Canvas does not allow drawing" document with SRVControls

Post by mcperes »

After inserting jpg in RVHeader, from a document with SRV Controls I got an error "canvas does not allow drawing".........
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: "Canvas does not allow drawing" document with SRVControls

Post by Sergey Tkachenko »

What version of ScaleRichView do you use?
Please give me step-by-step instructions how to reproduce.
mcperes
Posts: 6
Joined: Thu Jan 04, 2018 10:38 pm

Re: "Canvas does not allow drawing" document with SRVControls

Post by mcperes »

try
editor1.srv.RVHeader.Canvas.lock;
cabec:=TJpegImage.create;
cabec.loadfromfile(vCaminhoImagens+'\logo.'+formatzero(5,strtoint(gCodigoClinica))+'.jpg');
editor1.srv.RVHeader.clear;
editor1.srv.RVHeader.InsertPicture('cabec', cabec, rvvaLeft);
editor1.srv.RVHeader.Visible:=true;
editor1.srv.RVHeader.Format;
cabec.Free;
finally
editor1.srv.RVHeader.Canvas.unlock;
end;

but after, when move mouse over document .rvf with control insert show error...
mcperes
Posts: 6
Joined: Thu Jan 04, 2018 10:38 pm

Re: "Canvas does not allow drawing" document with SRVControls

Post by mcperes »

7.7.2 d 10 berlin
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: "Canvas does not allow drawing" document with SRVControls

Post by Sergey Tkachenko »

You must not free the image inserted in TRichView/ScaleRichView. It is owned by the editor and will be freed by the editor.

By the way, if you want to insert an image in a header as an editing operation, the code should be:

Code: Select all

// srv must be formatted when calling this code, and RVHeader must not be hidden
cabec:=TJpegImage.create;
cabec.loadfromfile(vCaminhoImagens+'\logo.'+formatzero(5,strtoint(gCodigoClinica))+'.jpg');
editor1.srv.StartEditing(srvrveHeader);
editor1.srv.RVHeader.InsertPicture('cabec', cabec, rvvaLeft);

If you want to generate a document containing an image in the header:

Code: Select all

// srv must be either unformatted, or the main editor must be active
// if srv is formatted, you can make sure that the main editor is active by calling editor1.srv.StartEditing(srvrveMain)
// before this code
cabec:=TJpegImage.create;
cabec.loadfromfile(vCaminhoImagens+'\logo.'+formatzero(5,strtoint(gCodigoClinica))+'.jpg');
with editor1.srv.SubDocuments[srvhftNormalHeader] do
begin
  Clear;
  AddPicture('cabec', cabec, 0, rvvaLeft);
  Add('', 0); // for any case, adding one non-floating text object in the header)
 end;
editor1.srv.Format;
Post Reply