Page 1 of 1

"Canvas does not allow drawing" document with SRVControls

Posted: Fri Feb 21, 2020 6:41 pm
by mcperes
After inserting jpg in RVHeader, from a document with SRV Controls I got an error "canvas does not allow drawing".........

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

Posted: Fri Feb 21, 2020 7:25 pm
by Sergey Tkachenko
What version of ScaleRichView do you use?
Please give me step-by-step instructions how to reproduce.

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

Posted: Fri Feb 21, 2020 8:57 pm
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...

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

Posted: Fri Feb 21, 2020 8:58 pm
by mcperes
7.7.2 d 10 berlin

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

Posted: Sat Feb 22, 2020 7:57 am
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;