Page 1 of 1

Protect Content of RichViewEdit

Posted: Thu May 12, 2011 8:03 pm
by charles.lambert
Hi,

I want to protect the content of a RichViewEdit and then give the user the possibility to add some text to it without being able to delete/modify anything. What I'm currently doing is that I apply a textstyle and a parastyle to the text in the RichViewEdit. Both style contain every protection options. Then I add a new line with a text style that doesn't contain any protection and that allows the user to type in some text. The problem is, if the user deletes everything until the cursor get to the protected part and then he tries to type in something, he won't be able because the current text is now affected with the protection style.

Here's the code I have to protect the in RichViewEdit

Code: Select all

procedure TFormDesigner.ProtectRVEdit(ARVEdit: TRichViewEdit);
begin
   ARVEdit.ApplyTextStyle(6);
   ARVEdit.ApplyParaStyle(2);
   ARVEdit.AddNL('', 0, 0);
   ARVEdit.AddNL('', 0, 0);
   ARVEdit.Format;
end;
TextStyle number 6 has all those protection options : [rvprStyleProtect, rvprStyleSplitProtect, rvprModifyProtect, rvprDeleteProtect,
rvprConcateProtect, rvprRVFInsertProtect, rvprDoNotAutoSwitch,rvprParaStartProtect,
rvprSticking, rvprSticking2, rvprSticking3, rvprStickToTop, rvprStickToBottom];

ParaStyle has all those protection options : [rvpaoReadOnly, rvpaoStyleProtect, rvpaoDoNotWantReturns];

Just to make sure everything is clear, I want to Protect the content of a RichViewEdit and then allow the user to add some text without being able to delete/modify anything that was previously protected.

Regards,

- Charles

Posted: Fri May 13, 2011 5:53 am
by Sergey Tkachenko
rvprStickToTop does not allow inserting before this text (if it starts the document).
rvprStickToBottom does not allow inserting after this text (if it ends the document).
Remove these options.

Posted: Fri May 13, 2011 1:37 pm
by charles.lambert
Thanks a lot